@jamesmurdza/opencode-daytona 0.1.21 → 0.1.23
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 +2 -2
- package/.opencode/plugin/daytona/core/logger.js +28 -15
- package/.opencode/plugin/daytona/core/logger.js.map +1 -1
- package/.opencode/plugin/daytona/core/project-data-storage.d.ts +11 -7
- package/.opencode/plugin/daytona/core/project-data-storage.js +84 -43
- package/.opencode/plugin/daytona/core/project-data-storage.js.map +1 -1
- package/.opencode/plugin/daytona/core/session-manager.d.ts +5 -2
- package/.opencode/plugin/daytona/core/session-manager.js +113 -60
- package/.opencode/plugin/daytona/core/session-manager.js.map +1 -1
- 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 +10 -8
- package/.opencode/plugin/daytona/core/types.js +10 -6
- package/.opencode/plugin/daytona/core/types.js.map +1 -1
- package/.opencode/plugin/daytona/git/host-git-manager.d.ts +34 -7
- package/.opencode/plugin/daytona/git/host-git-manager.js +254 -68
- package/.opencode/plugin/daytona/git/host-git-manager.js.map +1 -1
- package/.opencode/plugin/daytona/git/index.d.ts +4 -1
- package/.opencode/plugin/daytona/git/index.js +9 -1
- package/.opencode/plugin/daytona/git/index.js.map +1 -1
- package/.opencode/plugin/daytona/git/sandbox-git-manager.d.ts +5 -1
- package/.opencode/plugin/daytona/git/sandbox-git-manager.js +23 -12
- package/.opencode/plugin/daytona/git/sandbox-git-manager.js.map +1 -1
- package/.opencode/plugin/daytona/git/session-git-manager.d.ts +19 -3
- package/.opencode/plugin/daytona/git/session-git-manager.js +80 -43
- package/.opencode/plugin/daytona/git/session-git-manager.js.map +1 -1
- package/.opencode/plugin/daytona/index.d.ts +131 -23
- package/.opencode/plugin/daytona/index.js +27 -16
- package/.opencode/plugin/daytona/index.js.map +1 -1
- package/.opencode/plugin/daytona/plugins/custom-tools.d.ts +129 -5
- package/.opencode/plugin/daytona/plugins/custom-tools.js +15 -13
- package/.opencode/plugin/daytona/plugins/custom-tools.js.map +1 -1
- package/.opencode/plugin/daytona/plugins/session-events.d.ts +10 -0
- package/.opencode/plugin/daytona/plugins/session-events.js +51 -0
- package/.opencode/plugin/daytona/plugins/session-events.js.map +1 -0
- package/.opencode/plugin/daytona/plugins/system-transform.d.ts +8 -5
- package/.opencode/plugin/daytona/plugins/system-transform.js +19 -15
- package/.opencode/plugin/daytona/plugins/system-transform.js.map +1 -1
- package/.opencode/plugin/daytona/tools/bash.d.ts +7 -3
- package/.opencode/plugin/daytona/tools/bash.js +16 -5
- package/.opencode/plugin/daytona/tools/bash.js.map +1 -1
- package/.opencode/plugin/daytona/tools/edit.d.ts +6 -2
- package/.opencode/plugin/daytona/tools/edit.js +13 -5
- package/.opencode/plugin/daytona/tools/edit.js.map +1 -1
- package/.opencode/plugin/daytona/tools/get-preview-url.d.ts +6 -2
- package/.opencode/plugin/daytona/tools/get-preview-url.js +11 -3
- package/.opencode/plugin/daytona/tools/get-preview-url.js.map +1 -1
- package/.opencode/plugin/daytona/tools/glob.d.ts +6 -2
- package/.opencode/plugin/daytona/tools/glob.js +11 -3
- package/.opencode/plugin/daytona/tools/glob.js.map +1 -1
- package/.opencode/plugin/daytona/tools/grep.d.ts +6 -2
- package/.opencode/plugin/daytona/tools/grep.js +11 -3
- package/.opencode/plugin/daytona/tools/grep.js.map +1 -1
- package/.opencode/plugin/daytona/tools/ls.d.ts +6 -2
- package/.opencode/plugin/daytona/tools/ls.js +11 -3
- package/.opencode/plugin/daytona/tools/ls.js.map +1 -1
- package/.opencode/plugin/daytona/tools/lsp.d.ts +6 -2
- package/.opencode/plugin/daytona/tools/lsp.js +13 -5
- package/.opencode/plugin/daytona/tools/lsp.js.map +1 -1
- package/.opencode/plugin/daytona/tools/multiedit.d.ts +6 -2
- package/.opencode/plugin/daytona/tools/multiedit.js +14 -6
- package/.opencode/plugin/daytona/tools/multiedit.js.map +1 -1
- package/.opencode/plugin/daytona/tools/patch.d.ts +7 -5
- package/.opencode/plugin/daytona/tools/patch.js +13 -13
- package/.opencode/plugin/daytona/tools/patch.js.map +1 -1
- package/.opencode/plugin/daytona/tools/read.d.ts +6 -2
- package/.opencode/plugin/daytona/tools/read.js +11 -3
- package/.opencode/plugin/daytona/tools/read.js.map +1 -1
- package/.opencode/plugin/daytona/tools/write.d.ts +6 -2
- package/.opencode/plugin/daytona/tools/write.js +12 -4
- package/.opencode/plugin/daytona/tools/write.js.map +1 -1
- package/.opencode/plugin/daytona/tools.d.ts +14 -16
- package/.opencode/plugin/daytona/tools.js +31 -23
- package/.opencode/plugin/daytona/tools.js.map +1 -1
- package/.opencode/plugin/index.d.ts +7 -4
- package/.opencode/plugin/index.js +12 -3
- package/.opencode/plugin/index.js.map +1 -1
- package/README.md +68 -29
- package/package.json +34 -17
- package/.opencode/plugin/daytona/core/logger.d.ts.map +0 -1
- package/.opencode/plugin/daytona/core/project-data-storage.d.ts.map +0 -1
- package/.opencode/plugin/daytona/core/session-manager.d.ts.map +0 -1
- package/.opencode/plugin/daytona/core/types.d.ts.map +0 -1
- package/.opencode/plugin/daytona/git/host-git-manager.d.ts.map +0 -1
- package/.opencode/plugin/daytona/git/index.d.ts.map +0 -1
- package/.opencode/plugin/daytona/git/sandbox-git-manager.d.ts.map +0 -1
- package/.opencode/plugin/daytona/git/session-git-manager.d.ts.map +0 -1
- package/.opencode/plugin/daytona/index.d.ts.map +0 -1
- package/.opencode/plugin/daytona/plugins/custom-tools.d.ts.map +0 -1
- package/.opencode/plugin/daytona/plugins/index.d.ts +0 -8
- package/.opencode/plugin/daytona/plugins/index.d.ts.map +0 -1
- package/.opencode/plugin/daytona/plugins/index.js +0 -8
- package/.opencode/plugin/daytona/plugins/index.js.map +0 -1
- package/.opencode/plugin/daytona/plugins/session-cleanup.d.ts +0 -8
- package/.opencode/plugin/daytona/plugins/session-cleanup.d.ts.map +0 -1
- package/.opencode/plugin/daytona/plugins/session-cleanup.js +0 -38
- package/.opencode/plugin/daytona/plugins/session-cleanup.js.map +0 -1
- package/.opencode/plugin/daytona/plugins/session-idle-auto-commit.d.ts +0 -7
- package/.opencode/plugin/daytona/plugins/session-idle-auto-commit.d.ts.map +0 -1
- package/.opencode/plugin/daytona/plugins/session-idle-auto-commit.js +0 -46
- package/.opencode/plugin/daytona/plugins/session-idle-auto-commit.js.map +0 -1
- package/.opencode/plugin/daytona/plugins/system-transform.d.ts.map +0 -1
- package/.opencode/plugin/daytona/tools/bash.d.ts.map +0 -1
- package/.opencode/plugin/daytona/tools/edit.d.ts.map +0 -1
- package/.opencode/plugin/daytona/tools/get-preview-url.d.ts.map +0 -1
- package/.opencode/plugin/daytona/tools/glob.d.ts.map +0 -1
- package/.opencode/plugin/daytona/tools/grep.d.ts.map +0 -1
- package/.opencode/plugin/daytona/tools/ls.d.ts.map +0 -1
- package/.opencode/plugin/daytona/tools/lsp.d.ts.map +0 -1
- package/.opencode/plugin/daytona/tools/multiedit.d.ts.map +0 -1
- package/.opencode/plugin/daytona/tools/patch.d.ts.map +0 -1
- package/.opencode/plugin/daytona/tools/read.d.ts.map +0 -1
- package/.opencode/plugin/daytona/tools/write.d.ts.map +0 -1
- package/.opencode/plugin/daytona/tools.d.ts.map +0 -1
- package/.opencode/plugin/index.d.ts.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
3
4
|
*/
|
|
4
5
|
import type { LogLevel } from './types';
|
|
5
6
|
export declare function setLogFilePath(path: string): void;
|
|
@@ -12,4 +13,3 @@ declare class Logger {
|
|
|
12
13
|
}
|
|
13
14
|
export declare const logger: Logger;
|
|
14
15
|
export {};
|
|
15
|
-
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1,11 +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.logger = void 0;
|
|
8
|
+
exports.setLogFilePath = setLogFilePath;
|
|
1
9
|
/**
|
|
2
10
|
* Logger class for handling plugin logging
|
|
3
11
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
12
|
+
const fs_1 = require("fs");
|
|
13
|
+
const path_1 = require("path");
|
|
14
|
+
const types_1 = require("./types");
|
|
7
15
|
let logFilePath;
|
|
8
|
-
|
|
16
|
+
function setLogFilePath(path) {
|
|
9
17
|
logFilePath = path;
|
|
10
18
|
}
|
|
11
19
|
class Logger {
|
|
@@ -14,20 +22,25 @@ class Logger {
|
|
|
14
22
|
throw new Error('Logger file path not set. Call setLogFilePath(path) before use.');
|
|
15
23
|
return logFilePath;
|
|
16
24
|
}
|
|
17
|
-
log(message, level = LOG_LEVEL_INFO) {
|
|
25
|
+
log(message, level = types_1.LOG_LEVEL_INFO) {
|
|
18
26
|
// Ensure log directory exists
|
|
19
27
|
try {
|
|
20
|
-
mkdirSync(dirname(this.logFile), { recursive: true });
|
|
28
|
+
(0, fs_1.mkdirSync)((0, path_1.dirname)(this.logFile), { recursive: true });
|
|
21
29
|
}
|
|
22
30
|
catch (err) {
|
|
23
31
|
// Directory may already exist, ignore
|
|
24
32
|
}
|
|
25
|
-
//
|
|
33
|
+
// Trim log file if it exceeds 3MB (keep last 1MB)
|
|
26
34
|
try {
|
|
27
|
-
const stats = statSync(this.logFile);
|
|
28
|
-
const maxSize =
|
|
35
|
+
const stats = (0, fs_1.statSync)(this.logFile);
|
|
36
|
+
const maxSize = 3 * 1024 * 1024;
|
|
37
|
+
const keepSize = 1024 * 1024;
|
|
29
38
|
if (stats.size > maxSize) {
|
|
30
|
-
|
|
39
|
+
const content = (0, fs_1.readFileSync)(this.logFile, 'utf8');
|
|
40
|
+
const trimmed = content.slice(-keepSize);
|
|
41
|
+
// Drop partial first line so we don't start mid-log
|
|
42
|
+
const firstNewline = trimmed.indexOf('\n');
|
|
43
|
+
(0, fs_1.writeFileSync)(this.logFile, firstNewline >= 0 ? trimmed.slice(firstNewline + 1) : trimmed);
|
|
31
44
|
}
|
|
32
45
|
}
|
|
33
46
|
catch (err) {
|
|
@@ -35,17 +48,17 @@ class Logger {
|
|
|
35
48
|
}
|
|
36
49
|
const timestamp = new Date().toISOString();
|
|
37
50
|
const logEntry = `[${timestamp}] [${level}] ${message}\n`;
|
|
38
|
-
appendFileSync(this.logFile, logEntry);
|
|
51
|
+
(0, fs_1.appendFileSync)(this.logFile, logEntry);
|
|
39
52
|
}
|
|
40
53
|
info(message) {
|
|
41
|
-
this.log(message, LOG_LEVEL_INFO);
|
|
54
|
+
this.log(message, types_1.LOG_LEVEL_INFO);
|
|
42
55
|
}
|
|
43
56
|
error(message) {
|
|
44
|
-
this.log(message, LOG_LEVEL_ERROR);
|
|
57
|
+
this.log(message, types_1.LOG_LEVEL_ERROR);
|
|
45
58
|
}
|
|
46
59
|
warn(message) {
|
|
47
|
-
this.log(message, LOG_LEVEL_WARN);
|
|
60
|
+
this.log(message, types_1.LOG_LEVEL_WARN);
|
|
48
61
|
}
|
|
49
62
|
}
|
|
50
|
-
|
|
63
|
+
exports.logger = new Logger();
|
|
51
64
|
//# sourceMappingURL=logger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../../../../../libs/opencode-plugin/.opencode/plugin/daytona/core/logger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAaH,wCAEC;AAbD;;GAEG;AAEH,2BAAqF;AACrF,+BAA8B;AAE9B,mCAAyE;AAEzE,IAAI,WAA+B,CAAA;AAEnC,S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;QACD,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;QAC1C,MAAM,QAAQ,GAAG,IAAI,SAAS,MAAM,KAAK,KAAK,OAAO,IAAI,CAAA;QACzD,IAAA,mBAAc,EAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IACxC,CAAC;IAED,IAAI,CAAC,OAAe;QAClB,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,sBAAc,CAAC,CAAA;IACnC,CAAC;IAED,KAAK,CAAC,OAAe;QACnB,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,uBAAe,CAAC,CAAA;IACpC,CAAC;IAED,IAAI,CAAC,OAAe;QAClB,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,sBAAc,CAAC,CAAA;IACnC,CAAC;CACF;AAEY,QAAA,MAAM,GAAG,IAAI,MAAM,EAAE,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import type { ProjectSessionData, SessionInfo } from './types';
|
|
6
6
|
export declare class ProjectDataStorage {
|
|
@@ -10,18 +10,23 @@ export declare class ProjectDataStorage {
|
|
|
10
10
|
* Get the file path for a project's session data
|
|
11
11
|
*/
|
|
12
12
|
private getProjectFilePath;
|
|
13
|
+
/**
|
|
14
|
+
* List known project IDs from storage.
|
|
15
|
+
*/
|
|
16
|
+
private listProjectIds;
|
|
13
17
|
/**
|
|
14
18
|
* Load project session data from disk
|
|
15
19
|
*/
|
|
16
20
|
load(projectId: string): ProjectSessionData | null;
|
|
17
21
|
/**
|
|
18
|
-
*
|
|
22
|
+
* Get a session for a project. If not found in the requested project, search all other
|
|
23
|
+
* projects on disk and, if found, migrate it into the requested project.
|
|
19
24
|
*/
|
|
20
|
-
|
|
25
|
+
getSession(projectId: string, worktree: string, sessionId: string): SessionInfo | undefined;
|
|
21
26
|
/**
|
|
22
|
-
*
|
|
27
|
+
* Save project session data to disk
|
|
23
28
|
*/
|
|
24
|
-
|
|
29
|
+
save(projectId: string, worktree: string, sessions: Record<string, SessionInfo>): void;
|
|
25
30
|
/**
|
|
26
31
|
* Get branch number for a sandbox
|
|
27
32
|
*/
|
|
@@ -35,4 +40,3 @@ export declare class ProjectDataStorage {
|
|
|
35
40
|
*/
|
|
36
41
|
removeSession(projectId: string, worktree: string, sessionId: string): void;
|
|
37
42
|
}
|
|
38
|
-
//# sourceMappingURL=project-data-storage.d.ts.map
|
|
@@ -1,24 +1,45 @@
|
|
|
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.ProjectDataStorage = void 0;
|
|
1
8
|
/**
|
|
2
9
|
* Handles file storage operations for project session data
|
|
3
10
|
* Stores data per-project in ~/.local/share/opencode/storage/daytona/{projectId}.json
|
|
4
11
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
const fs_1 = require("fs");
|
|
13
|
+
const path_1 = require("path");
|
|
14
|
+
const logger_1 = require("./logger");
|
|
15
|
+
class ProjectDataStorage {
|
|
9
16
|
storageDir;
|
|
10
17
|
constructor(storageDir) {
|
|
11
18
|
this.storageDir = storageDir;
|
|
12
19
|
// Ensure storage directory exists
|
|
13
|
-
if (!existsSync(this.storageDir)) {
|
|
14
|
-
mkdirSync(this.storageDir, { recursive: true });
|
|
20
|
+
if (!(0, fs_1.existsSync)(this.storageDir)) {
|
|
21
|
+
(0, fs_1.mkdirSync)(this.storageDir, { recursive: true });
|
|
15
22
|
}
|
|
16
23
|
}
|
|
17
24
|
/**
|
|
18
25
|
* Get the file path for a project's session data
|
|
19
26
|
*/
|
|
20
27
|
getProjectFilePath(projectId) {
|
|
21
|
-
return join(this.storageDir, `${projectId}.json`);
|
|
28
|
+
return (0, path_1.join)(this.storageDir, `${projectId}.json`);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* List known project IDs from storage.
|
|
32
|
+
*/
|
|
33
|
+
listProjectIds() {
|
|
34
|
+
try {
|
|
35
|
+
return (0, fs_1.readdirSync)(this.storageDir)
|
|
36
|
+
.filter((name) => name.endsWith('.json'))
|
|
37
|
+
.map((name) => name.slice(0, -'.json'.length));
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
logger_1.logger.error(`Failed to list project data files: ${err}`);
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
22
43
|
}
|
|
23
44
|
/**
|
|
24
45
|
* Load project session data from disk
|
|
@@ -26,49 +47,73 @@ export class ProjectDataStorage {
|
|
|
26
47
|
load(projectId) {
|
|
27
48
|
const filePath = this.getProjectFilePath(projectId);
|
|
28
49
|
try {
|
|
29
|
-
if (existsSync(filePath)) {
|
|
30
|
-
return JSON.parse(readFileSync(filePath, 'utf-8'));
|
|
50
|
+
if ((0, fs_1.existsSync)(filePath)) {
|
|
51
|
+
return JSON.parse((0, fs_1.readFileSync)(filePath, 'utf-8'));
|
|
31
52
|
}
|
|
32
53
|
}
|
|
33
54
|
catch (err) {
|
|
34
|
-
logger.error(`Failed to load project data for ${projectId}: ${err}`);
|
|
55
|
+
logger_1.logger.error(`Failed to load project data for ${projectId}: ${err}`);
|
|
35
56
|
}
|
|
36
57
|
return null;
|
|
37
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Get a session for a project. If not found in the requested project, search all other
|
|
61
|
+
* projects on disk and, if found, migrate it into the requested project.
|
|
62
|
+
*/
|
|
63
|
+
getSession(projectId, worktree, sessionId) {
|
|
64
|
+
const current = this.load(projectId);
|
|
65
|
+
const currentSession = current?.sessions?.[sessionId];
|
|
66
|
+
if (currentSession) {
|
|
67
|
+
return currentSession;
|
|
68
|
+
}
|
|
69
|
+
// Look in other projects and migrate if found.
|
|
70
|
+
for (const otherProjectId of this.listProjectIds()) {
|
|
71
|
+
if (otherProjectId === projectId)
|
|
72
|
+
continue;
|
|
73
|
+
const otherData = this.load(otherProjectId);
|
|
74
|
+
const found = otherData?.sessions?.[sessionId];
|
|
75
|
+
if (!found)
|
|
76
|
+
continue;
|
|
77
|
+
const destination = current ?? {
|
|
78
|
+
projectId,
|
|
79
|
+
worktree,
|
|
80
|
+
sessions: {},
|
|
81
|
+
};
|
|
82
|
+
// Remove from source first (best effort).
|
|
83
|
+
try {
|
|
84
|
+
delete otherData.sessions[sessionId];
|
|
85
|
+
this.save(otherProjectId, otherData.worktree, otherData.sessions);
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
logger_1.logger.warn(`Failed to remove session ${sessionId} from project ${otherProjectId}: ${err}`);
|
|
89
|
+
}
|
|
90
|
+
// Add to destination and persist.
|
|
91
|
+
destination.sessions[sessionId] = found;
|
|
92
|
+
// Prefer the worktree for the project we're actually operating on.
|
|
93
|
+
destination.worktree = worktree;
|
|
94
|
+
this.save(projectId, destination.worktree, destination.sessions);
|
|
95
|
+
logger_1.logger.info(`Migrated session ${sessionId} from project ${otherProjectId} to project ${projectId}`);
|
|
96
|
+
return found;
|
|
97
|
+
}
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
38
100
|
/**
|
|
39
101
|
* Save project session data to disk
|
|
40
102
|
*/
|
|
41
|
-
save(projectId, worktree, sessions
|
|
103
|
+
save(projectId, worktree, sessions) {
|
|
42
104
|
const filePath = this.getProjectFilePath(projectId);
|
|
43
105
|
const projectData = {
|
|
44
106
|
projectId,
|
|
45
107
|
worktree,
|
|
46
|
-
lastBranchNumber,
|
|
47
108
|
sessions,
|
|
48
109
|
};
|
|
49
110
|
try {
|
|
50
|
-
writeFileSync(filePath, JSON.stringify(projectData, null, 2));
|
|
51
|
-
logger.info(`Saved project data for ${projectId}`);
|
|
111
|
+
(0, fs_1.writeFileSync)(filePath, JSON.stringify(projectData, null, 2));
|
|
112
|
+
logger_1.logger.info(`Saved project data for ${projectId}`);
|
|
52
113
|
}
|
|
53
114
|
catch (err) {
|
|
54
|
-
logger.error(`Failed to save project data for ${projectId}: ${err}`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Get the next available branch number for a project
|
|
59
|
-
*/
|
|
60
|
-
getNextBranchNumber(projectId) {
|
|
61
|
-
const projectData = this.load(projectId);
|
|
62
|
-
if (!projectData) {
|
|
63
|
-
return 1;
|
|
115
|
+
logger_1.logger.error(`Failed to save project data for ${projectId}: ${err}`);
|
|
64
116
|
}
|
|
65
|
-
const branchNumbers = Object.values(projectData.sessions)
|
|
66
|
-
.map(s => s.branchNumber)
|
|
67
|
-
.filter((n) => n !== undefined);
|
|
68
|
-
// Use a persisted monotonic pointer so we never reuse deleted numbers.
|
|
69
|
-
const pointer = projectData.lastBranchNumber ?? 0;
|
|
70
|
-
const maxInSessions = branchNumbers.length > 0 ? Math.max(...branchNumbers) : 0;
|
|
71
|
-
return Math.max(pointer, maxInSessions) + 1;
|
|
72
117
|
}
|
|
73
118
|
/**
|
|
74
119
|
* Get branch number for a sandbox
|
|
@@ -78,7 +123,7 @@ export class ProjectDataStorage {
|
|
|
78
123
|
if (!projectData) {
|
|
79
124
|
return undefined;
|
|
80
125
|
}
|
|
81
|
-
const session = Object.values(projectData.sessions).find(s => s.sandboxId === sandboxId);
|
|
126
|
+
const session = Object.values(projectData.sessions).find((s) => s.sandboxId === sandboxId);
|
|
82
127
|
return session?.branchNumber;
|
|
83
128
|
}
|
|
84
129
|
/**
|
|
@@ -88,32 +133,28 @@ export class ProjectDataStorage {
|
|
|
88
133
|
const projectData = this.load(projectId) || {
|
|
89
134
|
projectId,
|
|
90
135
|
worktree,
|
|
91
|
-
lastBranchNumber: 0,
|
|
92
136
|
sessions: {},
|
|
93
137
|
};
|
|
94
138
|
const now = Date.now();
|
|
95
139
|
if (!projectData.sessions[sessionId]) {
|
|
96
|
-
// Assign branch number if not provided
|
|
97
|
-
const assignedBranchNumber = branchNumber ?? this.getNextBranchNumber(projectId);
|
|
98
140
|
projectData.sessions[sessionId] = {
|
|
99
141
|
sandboxId,
|
|
100
|
-
branchNumber:
|
|
142
|
+
...(branchNumber !== undefined ? { branchNumber } : {}),
|
|
101
143
|
created: now,
|
|
102
144
|
lastAccessed: now,
|
|
103
145
|
};
|
|
104
|
-
projectData.lastBranchNumber = Math.max(projectData.lastBranchNumber ?? 0, assignedBranchNumber);
|
|
105
146
|
}
|
|
106
147
|
else {
|
|
107
148
|
projectData.sessions[sessionId].sandboxId = sandboxId;
|
|
108
149
|
projectData.sessions[sessionId].lastAccessed = now;
|
|
109
150
|
// Only update branch number if it wasn't set before
|
|
110
151
|
if (projectData.sessions[sessionId].branchNumber === undefined) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
152
|
+
if (branchNumber !== undefined) {
|
|
153
|
+
projectData.sessions[sessionId].branchNumber = branchNumber;
|
|
154
|
+
}
|
|
114
155
|
}
|
|
115
156
|
}
|
|
116
|
-
this.save(projectId, worktree, projectData.sessions
|
|
157
|
+
this.save(projectId, worktree, projectData.sessions);
|
|
117
158
|
}
|
|
118
159
|
/**
|
|
119
160
|
* Remove a session from the project file
|
|
@@ -122,9 +163,9 @@ export class ProjectDataStorage {
|
|
|
122
163
|
const projectData = this.load(projectId);
|
|
123
164
|
if (projectData && projectData.sessions[sessionId]) {
|
|
124
165
|
delete projectData.sessions[sessionId];
|
|
125
|
-
|
|
126
|
-
this.save(projectId, worktree, projectData.sessions, projectData.lastBranchNumber);
|
|
166
|
+
this.save(projectId, worktree, projectData.sessions);
|
|
127
167
|
}
|
|
128
168
|
}
|
|
129
169
|
}
|
|
170
|
+
exports.ProjectDataStorage = ProjectDataStorage;
|
|
130
171
|
//# sourceMappingURL=project-data-storage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-data-storage.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"project-data-storage.js","sourceRoot":"","sources":["../../../../../../../libs/opencode-plugin/.opencode/plugin/daytona/core/project-data-storage.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;GAGG;AAEH,2BAAoF;AACpF,+BAA2B;AAC3B,qCAAiC;AAGjC,MAAa,kBAAkB;IACZ,UAAU,CAAQ;IAEnC,YAAY,UAAkB;QAC5B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAE5B,kCAAkC;QAClC,IAAI,CAAC,IAAA,eAAU,EAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YACjC,IAAA,cAAS,EAAC,IAAI,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QACjD,CAAC;IACH,CAAC;IAED;;OAEG;IACK,kBAAkB,CAAC,SAAiB;QAC1C,OAAO,IAAA,WAAI,EAAC,IAAI,CAAC,UAAU,EAAE,GAAG,SAAS,OAAO,CAAC,CAAA;IACnD,CAAC;IAED;;OAEG;IACK,cAAc;QACpB,IAAI,CAAC;YACH,OAAO,IAAA,gBAAW,EAAC,IAAI,CAAC,UAAU,CAAC;iBAChC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;iBACxC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;QAClD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,eAAM,CAAC,KAAK,CAAC,sCAAsC,GAAG,EAAE,CAAC,CAAA;YACzD,OAAO,EAAE,CAAA;QACX,CAAC;IACH,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,SAAiB;QACpB,MAAM,QAAQ,GAAG,IAAI,CAAC,kBAAkB,CAAC,SAA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AAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;IACtD,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,SAAiB,EAAE,QAAgB,EAAE,SAAiB;QAClE,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QACxC,IAAI,WAAW,IAAI,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YACnD,OAAO,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;YACtC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;QACtD,CAAC;IACH,CAAC;CACF;AA7KD,gDA6KC"}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
1
5
|
/**
|
|
2
6
|
* Manages Daytona sandbox sessions and persists session-sandbox mappings
|
|
3
7
|
* Stores data per-project in ~/.local/share/opencode/storage/daytona/{projectId}.json
|
|
@@ -9,7 +13,7 @@ export declare class DaytonaSessionManager {
|
|
|
9
13
|
private readonly dataStorage;
|
|
10
14
|
private sessionSandboxes;
|
|
11
15
|
private currentProjectId?;
|
|
12
|
-
|
|
16
|
+
readonly repoPath: string;
|
|
13
17
|
constructor(apiKey: string, storageDir: string, repoPath: string);
|
|
14
18
|
/**
|
|
15
19
|
* Check if a sandbox is fully initialized (has process property)
|
|
@@ -40,4 +44,3 @@ export declare class DaytonaSessionManager {
|
|
|
40
44
|
*/
|
|
41
45
|
deleteSandbox(sessionId: string, projectId: string): Promise<void>;
|
|
42
46
|
}
|
|
43
|
-
//# sourceMappingURL=session-manager.d.ts.map
|