@jamesmurdza/opencode-daytona 0.1.12 → 0.1.14
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.ts +50 -0
- package/.opencode/plugin/daytona/core/project-data-storage.ts +154 -0
- package/.opencode/plugin/daytona/core/session-manager.ts +170 -0
- package/.opencode/plugin/daytona/core/types.ts +68 -0
- package/.opencode/plugin/daytona/git/host-git-manager.ts +94 -0
- package/.opencode/plugin/daytona/git/index.ts +1 -0
- package/.opencode/plugin/daytona/git/sandbox-git-manager.ts +51 -0
- package/.opencode/plugin/daytona/git/session-git-manager.ts +65 -0
- package/.opencode/plugin/daytona/index.ts +50 -0
- package/.opencode/plugin/daytona/plugins/custom-tools.ts +20 -0
- package/.opencode/plugin/daytona/plugins/index.ts +8 -0
- package/.opencode/plugin/daytona/plugins/session-cleanup.ts +22 -0
- package/.opencode/plugin/daytona/plugins/session-idle-auto-commit.ts +30 -0
- package/.opencode/plugin/daytona/plugins/system-transform.ts +28 -0
- package/.opencode/plugin/daytona/tools/bash.ts +32 -0
- package/.opencode/plugin/daytona/tools/edit.ts +21 -0
- package/.opencode/plugin/daytona/tools/get-preview-url.ts +15 -0
- package/.opencode/plugin/daytona/tools/glob.ts +16 -0
- package/.opencode/plugin/daytona/tools/grep.ts +16 -0
- package/.opencode/plugin/daytona/tools/ls.ts +18 -0
- package/.opencode/plugin/daytona/tools/lsp.ts +15 -0
- package/.opencode/plugin/daytona/tools/multiedit.ts +32 -0
- package/.opencode/plugin/daytona/tools/patch.ts +21 -0
- package/.opencode/plugin/daytona/tools/read.ts +16 -0
- package/.opencode/plugin/daytona/tools/write.ts +16 -0
- package/.opencode/plugin/daytona/tools.ts +33 -0
- package/.opencode/plugin/{index.js → index.ts} +1 -2
- package/README.md +192 -0
- package/package.json +3 -12
- package/.opencode/plugin/daytona/index.d.ts +0 -25
- package/.opencode/plugin/daytona/index.d.ts.map +0 -1
- package/.opencode/plugin/daytona/index.js +0 -36
- package/.opencode/plugin/daytona/index.js.map +0 -1
- package/.opencode/plugin/daytona/logger.d.ts +0 -13
- package/.opencode/plugin/daytona/logger.d.ts.map +0 -1
- package/.opencode/plugin/daytona/logger.js +0 -26
- package/.opencode/plugin/daytona/logger.js.map +0 -1
- package/.opencode/plugin/daytona/plugins.d.ts +0 -22
- package/.opencode/plugin/daytona/plugins.d.ts.map +0 -1
- package/.opencode/plugin/daytona/plugins.js +0 -60
- package/.opencode/plugin/daytona/plugins.js.map +0 -1
- package/.opencode/plugin/daytona/session-manager.d.ts +0 -47
- package/.opencode/plugin/daytona/session-manager.d.ts.map +0 -1
- package/.opencode/plugin/daytona/session-manager.js +0 -171
- package/.opencode/plugin/daytona/session-manager.js.map +0 -1
- package/.opencode/plugin/daytona/tools.d.ts +0 -185
- package/.opencode/plugin/daytona/tools.d.ts.map +0 -1
- package/.opencode/plugin/daytona/tools.js +0 -232
- package/.opencode/plugin/daytona/tools.js.map +0 -1
- package/.opencode/plugin/daytona/types.d.ts +0 -32
- package/.opencode/plugin/daytona/types.d.ts.map +0 -1
- package/.opencode/plugin/daytona/types.js +0 -10
- package/.opencode/plugin/daytona/types.js.map +0 -1
- package/.opencode/plugin/index.d.ts +0 -6
- package/.opencode/plugin/index.d.ts.map +0 -1
- package/.opencode/plugin/index.js.map +0 -1
|
@@ -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"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OpenCode plugin implementations for Daytona sandbox integration
|
|
3
|
-
*/
|
|
4
|
-
import { EVENT_TYPE_SESSION_DELETED } from "./types";
|
|
5
|
-
import { createDaytonaTools } from "./tools";
|
|
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(logger, sessionManager) {
|
|
11
|
-
return async (pluginCtx) => {
|
|
12
|
-
logger.info('OpenCode started with Daytona plugin');
|
|
13
|
-
const projectId = pluginCtx.project.id;
|
|
14
|
-
const worktree = pluginCtx.project.worktree;
|
|
15
|
-
return {
|
|
16
|
-
tool: createDaytonaTools(sessionManager, projectId, worktree),
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Creates the session cleanup plugin for Daytona
|
|
22
|
-
* Automatically cleans up sandbox resources when sessions end
|
|
23
|
-
*/
|
|
24
|
-
export function createSessionCleanupPlugin(sessionManager) {
|
|
25
|
-
return async (pluginCtx) => {
|
|
26
|
-
const projectId = pluginCtx.project.id;
|
|
27
|
-
return {
|
|
28
|
-
/**
|
|
29
|
-
* Cleans up sandbox resources when a session is deleted
|
|
30
|
-
*/
|
|
31
|
-
event: async ({ event }) => {
|
|
32
|
-
if (event.type === EVENT_TYPE_SESSION_DELETED) {
|
|
33
|
-
const sessionId = event.properties.info.id;
|
|
34
|
-
await sessionManager.deleteSandbox(sessionId, projectId);
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Creates the system transform plugin for Daytona
|
|
42
|
-
* Adds Daytona-specific instructions to the system prompt
|
|
43
|
-
*/
|
|
44
|
-
export function createSystemTransformPlugin() {
|
|
45
|
-
return async (pluginCtx) => {
|
|
46
|
-
return {
|
|
47
|
-
"experimental.chat.system.transform": async (input, output) => {
|
|
48
|
-
output.system.push(`
|
|
49
|
-
## Daytona Sandbox Integration
|
|
50
|
-
This session is running with Daytona sandbox integration enabled.
|
|
51
|
-
All tool calls will execute in a Daytona sandbox environment.
|
|
52
|
-
The sandbox working directory is /home/daytona/.
|
|
53
|
-
Do NOT try to use the current working directory of the host system.
|
|
54
|
-
When executing long-running commands, use the 'background' option to run them asynchronously.
|
|
55
|
-
`);
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=plugins.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../../../.opencode/plugin/daytona/plugins.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAAc,EACd,cAAqC;IAErC,OAAO,KAAK,EAAE,SAAsB,EAAE,EAAE;QACtC,MAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;QACpD,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;QACvC,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC;QAE5C,OAAO;YACL,IAAI,EAAE,kBAAkB,CAAC,cAAc,EAAE,SAAS,EAAE,QAAQ,CAAC;SAC9D,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CACxC,cAAqC;IAErC,OAAO,KAAK,EAAE,SAAsB,EAAE,EAAE;QACtC,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;QAEvC,OAAO;YACL;;eAEG;YACH,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;gBACzB,IAAI,KAAK,CAAC,IAAI,KAAK,0BAA0B,EAAE,CAAC;oBAC9C,MAAM,SAAS,GAAI,KAA6B,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;oBACpE,MAAM,cAAc,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;gBAC3D,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,2BAA2B;IACzC,OAAO,KAAK,EAAE,SAAsB,EAAE,EAAE;QACtC,OAAO;YACL,oCAAoC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;gBAC5D,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;;;;;;;OAOpB,CAAC,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Manages Daytona sandbox sessions and persists session-sandbox mappings
|
|
3
|
-
* Stores data per-project in ~/.local/share/opencode/storage/daytona/{projectId}.json
|
|
4
|
-
*/
|
|
5
|
-
import { type Sandbox } from "@daytonaio/sdk";
|
|
6
|
-
import type { Logger } from "./logger";
|
|
7
|
-
export declare class DaytonaSessionManager {
|
|
8
|
-
private readonly apiKey;
|
|
9
|
-
private readonly storageDir;
|
|
10
|
-
private readonly logger;
|
|
11
|
-
private sessionSandboxes;
|
|
12
|
-
private currentProjectId?;
|
|
13
|
-
constructor(apiKey: string, storageDir: string, logger: Logger);
|
|
14
|
-
/**
|
|
15
|
-
* Get the file path for a project's session data
|
|
16
|
-
*/
|
|
17
|
-
private getProjectFilePath;
|
|
18
|
-
/**
|
|
19
|
-
* Load project session data from disk
|
|
20
|
-
*/
|
|
21
|
-
private loadProjectData;
|
|
22
|
-
/**
|
|
23
|
-
* Load sessions for a specific project into memory
|
|
24
|
-
*/
|
|
25
|
-
private loadProjectSessions;
|
|
26
|
-
/**
|
|
27
|
-
* Save project session data to disk
|
|
28
|
-
*/
|
|
29
|
-
private saveProjectData;
|
|
30
|
-
/**
|
|
31
|
-
* Update a single session in the project file
|
|
32
|
-
*/
|
|
33
|
-
private updateSession;
|
|
34
|
-
/**
|
|
35
|
-
* Set the current project context
|
|
36
|
-
*/
|
|
37
|
-
setProjectContext(projectId: string): void;
|
|
38
|
-
/**
|
|
39
|
-
* Get or create a sandbox for the given session ID
|
|
40
|
-
*/
|
|
41
|
-
getSandbox(sessionId: string, projectId: string, worktree: string): Promise<Sandbox>;
|
|
42
|
-
/**
|
|
43
|
-
* Delete the sandbox associated with the given session ID
|
|
44
|
-
*/
|
|
45
|
-
deleteSandbox(sessionId: string, projectId: string): Promise<void>;
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=session-manager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session-manager.d.ts","sourceRoot":"","sources":["../../../../.opencode/plugin/daytona/session-manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAW,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGvC,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,gBAAgB,CAAoB;IAC5C,OAAO,CAAC,gBAAgB,CAAC,CAAS;gBAEtB,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAY9D;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAI1B;;OAEG;IACH,OAAO,CAAC,eAAe;IAYvB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAU3B;;OAEG;IACH,OAAO,CAAC,eAAe;IAgBvB;;OAEG;IACH,OAAO,CAAC,aAAa;IAsBrB;;OAEG;IACH,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAO1C;;OAEG;IACG,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAyC1F;;OAEG;IACG,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAmBzE"}
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Manages Daytona sandbox sessions and persists session-sandbox mappings
|
|
3
|
-
* Stores data per-project in ~/.local/share/opencode/storage/daytona/{projectId}.json
|
|
4
|
-
*/
|
|
5
|
-
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
6
|
-
import { join } from "path";
|
|
7
|
-
import { Daytona } from "@daytonaio/sdk";
|
|
8
|
-
export class DaytonaSessionManager {
|
|
9
|
-
apiKey;
|
|
10
|
-
storageDir;
|
|
11
|
-
logger;
|
|
12
|
-
sessionSandboxes;
|
|
13
|
-
currentProjectId;
|
|
14
|
-
constructor(apiKey, storageDir, logger) {
|
|
15
|
-
this.apiKey = apiKey;
|
|
16
|
-
this.storageDir = storageDir;
|
|
17
|
-
this.logger = logger;
|
|
18
|
-
this.sessionSandboxes = new Map();
|
|
19
|
-
// Ensure storage directory exists
|
|
20
|
-
if (!existsSync(this.storageDir)) {
|
|
21
|
-
mkdirSync(this.storageDir, { recursive: true });
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Get the file path for a project's session data
|
|
26
|
-
*/
|
|
27
|
-
getProjectFilePath(projectId) {
|
|
28
|
-
return join(this.storageDir, `${projectId}.json`);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Load project session data from disk
|
|
32
|
-
*/
|
|
33
|
-
loadProjectData(projectId) {
|
|
34
|
-
const filePath = this.getProjectFilePath(projectId);
|
|
35
|
-
try {
|
|
36
|
-
if (existsSync(filePath)) {
|
|
37
|
-
return JSON.parse(readFileSync(filePath, 'utf-8'));
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
catch (err) {
|
|
41
|
-
this.logger.error(`Failed to load project data for ${projectId}: ${err}`);
|
|
42
|
-
}
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Load sessions for a specific project into memory
|
|
47
|
-
*/
|
|
48
|
-
loadProjectSessions(projectId) {
|
|
49
|
-
const projectData = this.loadProjectData(projectId);
|
|
50
|
-
if (projectData) {
|
|
51
|
-
for (const [sessionId, sessionInfo] of Object.entries(projectData.sessions)) {
|
|
52
|
-
this.sessionSandboxes.set(sessionId, { id: sessionInfo.sandboxId });
|
|
53
|
-
}
|
|
54
|
-
this.logger.info(`Loaded ${Object.keys(projectData.sessions).length} sessions for project ${projectId}`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Save project session data to disk
|
|
59
|
-
*/
|
|
60
|
-
saveProjectData(projectId, worktree, sessions) {
|
|
61
|
-
const filePath = this.getProjectFilePath(projectId);
|
|
62
|
-
const projectData = {
|
|
63
|
-
projectId,
|
|
64
|
-
worktree,
|
|
65
|
-
sessions,
|
|
66
|
-
};
|
|
67
|
-
try {
|
|
68
|
-
writeFileSync(filePath, JSON.stringify(projectData, null, 2));
|
|
69
|
-
this.logger.info(`Saved project data for ${projectId}`);
|
|
70
|
-
}
|
|
71
|
-
catch (err) {
|
|
72
|
-
this.logger.error(`Failed to save project data for ${projectId}: ${err}`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Update a single session in the project file
|
|
77
|
-
*/
|
|
78
|
-
updateSession(projectId, worktree, sessionId, sandboxId) {
|
|
79
|
-
const projectData = this.loadProjectData(projectId) || {
|
|
80
|
-
projectId,
|
|
81
|
-
worktree,
|
|
82
|
-
sessions: {},
|
|
83
|
-
};
|
|
84
|
-
const now = Date.now();
|
|
85
|
-
if (!projectData.sessions[sessionId]) {
|
|
86
|
-
projectData.sessions[sessionId] = {
|
|
87
|
-
sandboxId,
|
|
88
|
-
created: now,
|
|
89
|
-
lastAccessed: now,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
projectData.sessions[sessionId].sandboxId = sandboxId;
|
|
94
|
-
projectData.sessions[sessionId].lastAccessed = now;
|
|
95
|
-
}
|
|
96
|
-
this.saveProjectData(projectId, worktree, projectData.sessions);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Set the current project context
|
|
100
|
-
*/
|
|
101
|
-
setProjectContext(projectId) {
|
|
102
|
-
if (this.currentProjectId !== projectId) {
|
|
103
|
-
this.currentProjectId = projectId;
|
|
104
|
-
this.loadProjectSessions(projectId);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Get or create a sandbox for the given session ID
|
|
109
|
-
*/
|
|
110
|
-
async getSandbox(sessionId, projectId, worktree) {
|
|
111
|
-
if (!this.apiKey) {
|
|
112
|
-
this.logger.error('DAYTONA_API_KEY is not set. Cannot create or retrieve sandbox.');
|
|
113
|
-
throw new Error('DAYTONA_API_KEY is not set. Please set the environment variable to use Daytona sandboxes.');
|
|
114
|
-
}
|
|
115
|
-
// Load project sessions if needed
|
|
116
|
-
this.setProjectContext(projectId);
|
|
117
|
-
if (!this.sessionSandboxes.has(sessionId)) {
|
|
118
|
-
this.logger.info(`Creating new sandbox for session: ${sessionId} in project: ${projectId}`);
|
|
119
|
-
const daytona = new Daytona({ apiKey: this.apiKey });
|
|
120
|
-
const sandbox = await daytona.create();
|
|
121
|
-
this.sessionSandboxes.set(sessionId, sandbox);
|
|
122
|
-
this.updateSession(projectId, worktree, sessionId, sandbox.id);
|
|
123
|
-
this.logger.info(`Sandbox created successfully: ${sandbox.id}`);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
const sandboxInfo = this.sessionSandboxes.get(sessionId);
|
|
127
|
-
if (sandboxInfo && !('process' in sandboxInfo)) {
|
|
128
|
-
this.logger.info(`Reconnecting to sandbox: ${sandboxInfo.id}`);
|
|
129
|
-
const daytona = new Daytona({ apiKey: this.apiKey });
|
|
130
|
-
const sandbox = await daytona.create();
|
|
131
|
-
this.sessionSandboxes.set(sessionId, sandbox);
|
|
132
|
-
this.updateSession(projectId, worktree, sessionId, sandbox.id);
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
this.logger.info(`Reusing existing sandbox for session: ${sessionId}`);
|
|
136
|
-
// Update last accessed time
|
|
137
|
-
this.updateSession(projectId, worktree, sessionId, sandboxInfo.id);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
const sandbox = this.sessionSandboxes.get(sessionId);
|
|
141
|
-
if (!sandbox) {
|
|
142
|
-
throw new Error(`Failed to get sandbox for session: ${sessionId}`);
|
|
143
|
-
}
|
|
144
|
-
if (!('process' in sandbox)) {
|
|
145
|
-
throw new Error(`Sandbox is not fully initialized for session: ${sessionId}`);
|
|
146
|
-
}
|
|
147
|
-
return sandbox;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Delete the sandbox associated with the given session ID
|
|
151
|
-
*/
|
|
152
|
-
async deleteSandbox(sessionId, projectId) {
|
|
153
|
-
const sandbox = this.sessionSandboxes.get(sessionId);
|
|
154
|
-
if (sandbox && 'delete' in sandbox) {
|
|
155
|
-
this.logger.info(`Removing sandbox for session: ${sessionId}`);
|
|
156
|
-
await sandbox.delete();
|
|
157
|
-
this.sessionSandboxes.delete(sessionId);
|
|
158
|
-
// Remove from project file
|
|
159
|
-
const projectData = this.loadProjectData(projectId);
|
|
160
|
-
if (projectData && projectData.sessions[sessionId]) {
|
|
161
|
-
delete projectData.sessions[sessionId];
|
|
162
|
-
this.saveProjectData(projectId, projectData.worktree, projectData.sessions);
|
|
163
|
-
}
|
|
164
|
-
this.logger.info(`Sandbox deleted successfully.`);
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
this.logger.warn(`No sandbox found for session: ${sessionId}`);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
//# sourceMappingURL=session-manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session-manager.js","sourceRoot":"","sources":["../../../../.opencode/plugin/daytona/session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C;YAC9E,CAAC;YAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iCAAiC,SAAS,EAAE,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tool implementations for Daytona sandbox integration
|
|
3
|
-
*/
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import type { ToolContext } from "@opencode-ai/plugin";
|
|
6
|
-
import type { DaytonaSessionManager } from "./session-manager";
|
|
7
|
-
export declare function createDaytonaTools(sessionManager: DaytonaSessionManager, projectId: string, worktree: string): {
|
|
8
|
-
/**
|
|
9
|
-
* Executes a shell command in the Daytona sandbox and returns the output
|
|
10
|
-
* @param command - Shell command to execute
|
|
11
|
-
* @param background - Whether to run the command in the background
|
|
12
|
-
*/
|
|
13
|
-
bash: {
|
|
14
|
-
description: string;
|
|
15
|
-
args: {
|
|
16
|
-
command: z.ZodString;
|
|
17
|
-
background: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
-
};
|
|
19
|
-
execute(args: {
|
|
20
|
-
command: string;
|
|
21
|
-
background?: boolean;
|
|
22
|
-
}, ctx: ToolContext): Promise<string>;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Reads and returns the contents of a file from the sandbox
|
|
26
|
-
* @param filePath - Path to the file to read
|
|
27
|
-
*/
|
|
28
|
-
read: {
|
|
29
|
-
description: string;
|
|
30
|
-
args: {
|
|
31
|
-
filePath: z.ZodString;
|
|
32
|
-
};
|
|
33
|
-
execute(args: {
|
|
34
|
-
filePath: string;
|
|
35
|
-
}, ctx: ToolContext): Promise<string>;
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Writes content to a file in the sandbox, creating it if it doesn't exist
|
|
39
|
-
* @param filePath - Path to the file to write
|
|
40
|
-
* @param content - Content to write to the file
|
|
41
|
-
*/
|
|
42
|
-
write: {
|
|
43
|
-
description: string;
|
|
44
|
-
args: {
|
|
45
|
-
filePath: z.ZodString;
|
|
46
|
-
content: z.ZodString;
|
|
47
|
-
};
|
|
48
|
-
execute(args: {
|
|
49
|
-
filePath: string;
|
|
50
|
-
content: string;
|
|
51
|
-
}, ctx: ToolContext): Promise<string>;
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Replaces the first occurrence of a text pattern in a file
|
|
55
|
-
* @param filePath - Path to the file to edit
|
|
56
|
-
* @param oldString - Text to search for
|
|
57
|
-
* @param newString - Text to replace with
|
|
58
|
-
*/
|
|
59
|
-
edit: {
|
|
60
|
-
description: string;
|
|
61
|
-
args: {
|
|
62
|
-
filePath: z.ZodString;
|
|
63
|
-
oldString: z.ZodString;
|
|
64
|
-
newString: z.ZodString;
|
|
65
|
-
};
|
|
66
|
-
execute(args: {
|
|
67
|
-
filePath: string;
|
|
68
|
-
oldString: string;
|
|
69
|
-
newString: string;
|
|
70
|
-
}, ctx: ToolContext): Promise<string>;
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* Applies multiple text replacements to a file atomically
|
|
74
|
-
* @param filePath - Path to the file to edit
|
|
75
|
-
* @param edits - Array of {oldString, newString} pairs to apply
|
|
76
|
-
*/
|
|
77
|
-
multiedit: {
|
|
78
|
-
description: string;
|
|
79
|
-
args: {
|
|
80
|
-
filePath: z.ZodString;
|
|
81
|
-
edits: z.ZodArray<z.ZodObject<{
|
|
82
|
-
oldString: z.ZodString;
|
|
83
|
-
newString: z.ZodString;
|
|
84
|
-
}, z.core.$strip>>;
|
|
85
|
-
};
|
|
86
|
-
execute(args: {
|
|
87
|
-
filePath: string;
|
|
88
|
-
edits: Array<{
|
|
89
|
-
oldString: string;
|
|
90
|
-
newString: string;
|
|
91
|
-
}>;
|
|
92
|
-
}, ctx: ToolContext): Promise<string>;
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* Patches a file by replacing a code snippet with a new one
|
|
96
|
-
* @param filePath - Path to the file to patch
|
|
97
|
-
* @param oldSnippet - Code snippet to search for
|
|
98
|
-
* @param newSnippet - Code snippet to replace with
|
|
99
|
-
*/
|
|
100
|
-
patch: {
|
|
101
|
-
description: string;
|
|
102
|
-
args: {
|
|
103
|
-
filePath: z.ZodString;
|
|
104
|
-
oldSnippet: z.ZodString;
|
|
105
|
-
newSnippet: z.ZodString;
|
|
106
|
-
};
|
|
107
|
-
execute(args: {
|
|
108
|
-
filePath: string;
|
|
109
|
-
oldSnippet: string;
|
|
110
|
-
newSnippet: string;
|
|
111
|
-
}, ctx: ToolContext): Promise<string>;
|
|
112
|
-
};
|
|
113
|
-
/**
|
|
114
|
-
* Lists files and directories in the specified path (or working directory)
|
|
115
|
-
* @param dirPath - Optional directory path to list (defaults to working directory)
|
|
116
|
-
*/
|
|
117
|
-
ls: {
|
|
118
|
-
description: string;
|
|
119
|
-
args: {
|
|
120
|
-
dirPath: z.ZodOptional<z.ZodString>;
|
|
121
|
-
};
|
|
122
|
-
execute(args: {
|
|
123
|
-
dirPath?: string;
|
|
124
|
-
}, ctx: ToolContext): Promise<string>;
|
|
125
|
-
};
|
|
126
|
-
/**
|
|
127
|
-
* Searches for files matching a glob pattern in the sandbox
|
|
128
|
-
* @param pattern - Glob pattern to match files (e.g., "**\/*.ts")
|
|
129
|
-
*/
|
|
130
|
-
glob: {
|
|
131
|
-
description: string;
|
|
132
|
-
args: {
|
|
133
|
-
pattern: z.ZodString;
|
|
134
|
-
};
|
|
135
|
-
execute(args: {
|
|
136
|
-
pattern: string;
|
|
137
|
-
}, ctx: ToolContext): Promise<string>;
|
|
138
|
-
};
|
|
139
|
-
/**
|
|
140
|
-
* Searches for text patterns in files and returns matching lines
|
|
141
|
-
* @param pattern - Text pattern to search for
|
|
142
|
-
*/
|
|
143
|
-
grep: {
|
|
144
|
-
description: string;
|
|
145
|
-
args: {
|
|
146
|
-
pattern: z.ZodString;
|
|
147
|
-
};
|
|
148
|
-
execute(args: {
|
|
149
|
-
pattern: string;
|
|
150
|
-
}, ctx: ToolContext): Promise<string>;
|
|
151
|
-
};
|
|
152
|
-
/**
|
|
153
|
-
* Performs LSP (Language Server Protocol) operations for code intelligence (not yet implemented)
|
|
154
|
-
* @param op - LSP operation to perform
|
|
155
|
-
* @param filePath - Path to the file
|
|
156
|
-
* @param line - Line number
|
|
157
|
-
*/
|
|
158
|
-
lsp: {
|
|
159
|
-
description: string;
|
|
160
|
-
args: {
|
|
161
|
-
op: z.ZodString;
|
|
162
|
-
filePath: z.ZodString;
|
|
163
|
-
line: z.ZodNumber;
|
|
164
|
-
};
|
|
165
|
-
execute(args: {
|
|
166
|
-
op: string;
|
|
167
|
-
filePath: string;
|
|
168
|
-
line: number;
|
|
169
|
-
}, ctx: ToolContext): Promise<string>;
|
|
170
|
-
};
|
|
171
|
-
/**
|
|
172
|
-
* Gets a preview URL for the Daytona sandbox
|
|
173
|
-
* @param port - Port number to preview
|
|
174
|
-
*/
|
|
175
|
-
getPreviewURL: {
|
|
176
|
-
description: string;
|
|
177
|
-
args: {
|
|
178
|
-
port: z.ZodNumber;
|
|
179
|
-
};
|
|
180
|
-
execute(args: {
|
|
181
|
-
port: number;
|
|
182
|
-
}, ctx: ToolContext): Promise<string>;
|
|
183
|
-
};
|
|
184
|
-
};
|
|
185
|
-
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../../.opencode/plugin/daytona/tools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE/D,wBAAgB,kBAAkB,CAChC,cAAc,EAAE,qBAAqB,EACrC,SAAS,EAAE,MAAM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