replicas-engine 0.1.29 → 0.1.31
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/dist/src/index.js +54 -48
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -1099,51 +1099,49 @@ var CodexManager = class {
|
|
|
1099
1099
|
const normalizedImages = await normalizeImages(images);
|
|
1100
1100
|
tempImagePaths = await this.saveImagesToTempFiles(normalizedImages);
|
|
1101
1101
|
}
|
|
1102
|
-
const sandboxMode =
|
|
1103
|
-
if (
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
this.currentThreadId = event.thread_id;
|
|
1137
|
-
await saveEngineState({ codexThreadId: this.currentThreadId });
|
|
1138
|
-
console.log(`[CodexManager] Captured and persisted thread ID: ${this.currentThreadId}`);
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
if (!this.currentThreadId && this.currentThread.id) {
|
|
1142
|
-
this.currentThreadId = this.currentThread.id;
|
|
1102
|
+
const sandboxMode = "danger-full-access";
|
|
1103
|
+
if (this.currentThreadId) {
|
|
1104
|
+
this.currentThread = this.codex.resumeThread(this.currentThreadId, {
|
|
1105
|
+
workingDirectory: this.workingDirectory,
|
|
1106
|
+
skipGitRepoCheck: true,
|
|
1107
|
+
sandboxMode,
|
|
1108
|
+
model: model || DEFAULT_MODEL
|
|
1109
|
+
});
|
|
1110
|
+
} else {
|
|
1111
|
+
this.currentThread = this.codex.startThread({
|
|
1112
|
+
workingDirectory: this.workingDirectory,
|
|
1113
|
+
skipGitRepoCheck: true,
|
|
1114
|
+
sandboxMode,
|
|
1115
|
+
model: model || DEFAULT_MODEL
|
|
1116
|
+
});
|
|
1117
|
+
const startHooksInstruction = this.getStartHooksInstruction();
|
|
1118
|
+
const parts = [];
|
|
1119
|
+
if (this.baseSystemPrompt) {
|
|
1120
|
+
parts.push(this.baseSystemPrompt);
|
|
1121
|
+
}
|
|
1122
|
+
if (startHooksInstruction) {
|
|
1123
|
+
parts.push(startHooksInstruction);
|
|
1124
|
+
}
|
|
1125
|
+
if (customInstructions) {
|
|
1126
|
+
parts.push(customInstructions);
|
|
1127
|
+
}
|
|
1128
|
+
const combinedInstructions = parts.length > 0 ? parts.join("\n\n") : void 0;
|
|
1129
|
+
if (combinedInstructions) {
|
|
1130
|
+
message = combinedInstructions + "\n\n\n" + message;
|
|
1131
|
+
}
|
|
1132
|
+
const { events: events2 } = await this.currentThread.runStreamed("Hello");
|
|
1133
|
+
for await (const event of events2) {
|
|
1134
|
+
if (event.type === "thread.started") {
|
|
1135
|
+
this.currentThreadId = event.thread_id;
|
|
1143
1136
|
await saveEngineState({ codexThreadId: this.currentThreadId });
|
|
1144
|
-
console.log(`[CodexManager] Captured and persisted thread ID
|
|
1137
|
+
console.log(`[CodexManager] Captured and persisted thread ID: ${this.currentThreadId}`);
|
|
1145
1138
|
}
|
|
1146
1139
|
}
|
|
1140
|
+
if (!this.currentThreadId && this.currentThread.id) {
|
|
1141
|
+
this.currentThreadId = this.currentThread.id;
|
|
1142
|
+
await saveEngineState({ codexThreadId: this.currentThreadId });
|
|
1143
|
+
console.log(`[CodexManager] Captured and persisted thread ID from thread.id: ${this.currentThreadId}`);
|
|
1144
|
+
}
|
|
1147
1145
|
}
|
|
1148
1146
|
let input;
|
|
1149
1147
|
if (tempImagePaths.length > 0) {
|
|
@@ -1890,6 +1888,7 @@ import { existsSync as existsSync3 } from "fs";
|
|
|
1890
1888
|
import { join as join5, basename } from "path";
|
|
1891
1889
|
import { homedir as homedir5 } from "os";
|
|
1892
1890
|
var PLANS_DIR = join5(homedir5(), ".replicas", "plans");
|
|
1891
|
+
var CLAUDE_PLANS_DIR = join5(homedir5(), ".claude", "plans");
|
|
1893
1892
|
function isValidFilename(filename) {
|
|
1894
1893
|
if (!filename.endsWith(".md")) {
|
|
1895
1894
|
return false;
|
|
@@ -1901,11 +1900,14 @@ async function ensurePlansDir() {
|
|
|
1901
1900
|
if (!existsSync3(PLANS_DIR)) {
|
|
1902
1901
|
await mkdir5(PLANS_DIR, { recursive: true });
|
|
1903
1902
|
}
|
|
1903
|
+
if (!existsSync3(CLAUDE_PLANS_DIR)) {
|
|
1904
|
+
await mkdir5(CLAUDE_PLANS_DIR, { recursive: true });
|
|
1905
|
+
}
|
|
1904
1906
|
}
|
|
1905
1907
|
async function listPlans() {
|
|
1906
1908
|
await ensurePlansDir();
|
|
1907
1909
|
try {
|
|
1908
|
-
const files = await readdir2(PLANS_DIR);
|
|
1910
|
+
const files = [...await readdir2(PLANS_DIR), ...await readdir2(CLAUDE_PLANS_DIR)];
|
|
1909
1911
|
return files.filter((file) => file.endsWith(".md")).sort((a, b) => a.localeCompare(b));
|
|
1910
1912
|
} catch {
|
|
1911
1913
|
return [];
|
|
@@ -1916,12 +1918,16 @@ async function getPlanContent(filename) {
|
|
|
1916
1918
|
throw new Error("Invalid filename");
|
|
1917
1919
|
}
|
|
1918
1920
|
await ensurePlansDir();
|
|
1919
|
-
const
|
|
1920
|
-
|
|
1921
|
-
|
|
1921
|
+
const safeName = basename(filename);
|
|
1922
|
+
const replicasPath = join5(PLANS_DIR, safeName);
|
|
1923
|
+
const claudePath = join5(CLAUDE_PLANS_DIR, safeName);
|
|
1924
|
+
if (existsSync3(replicasPath)) {
|
|
1925
|
+
return await readFile4(replicasPath, "utf-8");
|
|
1926
|
+
}
|
|
1927
|
+
if (existsSync3(claudePath)) {
|
|
1928
|
+
return await readFile4(claudePath, "utf-8");
|
|
1922
1929
|
}
|
|
1923
|
-
|
|
1924
|
-
return content;
|
|
1930
|
+
throw new Error("Plan not found");
|
|
1925
1931
|
}
|
|
1926
1932
|
|
|
1927
1933
|
// src/routes/plans.ts
|