ework-daemon 0.4.16 → 0.4.17
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/package.json +1 -1
- package/src/opencode.ts +22 -0
package/package.json
CHANGED
package/src/opencode.ts
CHANGED
|
@@ -153,6 +153,23 @@ export async function checkSessionOutput(
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
export async function opencodeSessionExists(dbPath: string, sessionId: string): Promise<boolean> {
|
|
157
|
+
let db: Database;
|
|
158
|
+
try {
|
|
159
|
+
db = new Database(dbPath, { readonly: true });
|
|
160
|
+
} catch {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
const row = db.prepare("SELECT 1 FROM session WHERE id = ? LIMIT 1").get(sessionId);
|
|
165
|
+
return !!row;
|
|
166
|
+
} catch {
|
|
167
|
+
return false;
|
|
168
|
+
} finally {
|
|
169
|
+
db.close();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
156
173
|
/**
|
|
157
174
|
* Default TakeoverStrategy: deterministic per-issue workdir under
|
|
158
175
|
* `<baseWorkdir>/<owner>--<repo>/<issueId>/<sessionName>`, with a best-effort
|
|
@@ -885,6 +902,11 @@ export class Engine {
|
|
|
885
902
|
const fromStrategy = await this.takeover.resumeOpenCodeSession(session);
|
|
886
903
|
if (fromStrategy) resumeSessionId = fromStrategy;
|
|
887
904
|
}
|
|
905
|
+
if (resumeSessionId && !(await opencodeSessionExists(this.cfg.opencode.dbPath, resumeSessionId))) {
|
|
906
|
+
log.warn(`stale opencode session ${resumeSessionId} not found in db, starting fresh`);
|
|
907
|
+
resumeSessionId = undefined;
|
|
908
|
+
await this.store.updateSession(session.id, { opencodeSessionId: undefined });
|
|
909
|
+
}
|
|
888
910
|
if (resumeSessionId) {
|
|
889
911
|
args.push("--session", resumeSessionId);
|
|
890
912
|
}
|