replicas-engine 0.1.30 → 0.1.32
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/chunk-ZXMDA7VB.js +16 -0
- package/dist/src/index.js +64 -44
- package/dist/src/lib-WNJM7YOZ.js +3011 -0
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
4
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
5
|
+
}) : x)(function(x) {
|
|
6
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
7
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
8
|
+
});
|
|
9
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
10
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
__require,
|
|
15
|
+
__commonJS
|
|
16
|
+
};
|
package/dist/src/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import "./chunk-ZXMDA7VB.js";
|
|
2
3
|
|
|
3
4
|
// src/index.ts
|
|
4
5
|
import "dotenv/config";
|
|
@@ -784,6 +785,23 @@ async function normalizeImages(images) {
|
|
|
784
785
|
return normalized;
|
|
785
786
|
}
|
|
786
787
|
|
|
788
|
+
// ../shared/src/sandbox.ts
|
|
789
|
+
var SANDBOX_LIFECYCLE = {
|
|
790
|
+
AUTO_STOP_MINUTES: 60,
|
|
791
|
+
AUTO_ARCHIVE_MINUTES: 60 * 24 * 7,
|
|
792
|
+
AUTO_DELETE_MINUTES: -1,
|
|
793
|
+
SSH_TOKEN_EXPIRATION_MINUTES: 3 * 60
|
|
794
|
+
};
|
|
795
|
+
|
|
796
|
+
// ../shared/src/prompts.ts
|
|
797
|
+
var GENERAL_INSTRUCTIONS_TAG = "general_instructions";
|
|
798
|
+
var CODEX_USER_INSTRUCTION_TAG = "user_instruction";
|
|
799
|
+
function wrapInTag(content, tag) {
|
|
800
|
+
return `<${tag}>
|
|
801
|
+
${content}
|
|
802
|
+
</${tag}>`;
|
|
803
|
+
}
|
|
804
|
+
|
|
787
805
|
// src/services/replicas-config.ts
|
|
788
806
|
import { readFile as readFile3, appendFile, writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
789
807
|
import { existsSync as existsSync2 } from "fs";
|
|
@@ -961,7 +979,8 @@ Commands: ${hooks.length}
|
|
|
961
979
|
* Get the system prompt from replicas.json
|
|
962
980
|
*/
|
|
963
981
|
getSystemPrompt() {
|
|
964
|
-
|
|
982
|
+
if (!this.config?.systemPrompt) return void 0;
|
|
983
|
+
return wrapInTag(this.config.systemPrompt, GENERAL_INSTRUCTIONS_TAG);
|
|
965
984
|
}
|
|
966
985
|
/**
|
|
967
986
|
* Get the full config object
|
|
@@ -1099,61 +1118,62 @@ var CodexManager = class {
|
|
|
1099
1118
|
const normalizedImages = await normalizeImages(images);
|
|
1100
1119
|
tempImagePaths = await this.saveImagesToTempFiles(normalizedImages);
|
|
1101
1120
|
}
|
|
1102
|
-
const sandboxMode =
|
|
1103
|
-
if (
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1121
|
+
const sandboxMode = "danger-full-access";
|
|
1122
|
+
if (this.currentThreadId) {
|
|
1123
|
+
this.currentThread = this.codex.resumeThread(this.currentThreadId, {
|
|
1124
|
+
workingDirectory: this.workingDirectory,
|
|
1125
|
+
skipGitRepoCheck: true,
|
|
1126
|
+
sandboxMode,
|
|
1127
|
+
model: model || DEFAULT_MODEL
|
|
1128
|
+
});
|
|
1129
|
+
} else {
|
|
1130
|
+
this.currentThread = this.codex.startThread({
|
|
1131
|
+
workingDirectory: this.workingDirectory,
|
|
1132
|
+
skipGitRepoCheck: true,
|
|
1133
|
+
sandboxMode,
|
|
1134
|
+
model: model || DEFAULT_MODEL
|
|
1135
|
+
});
|
|
1136
|
+
const startHooksInstruction = this.getStartHooksInstruction();
|
|
1137
|
+
const parts = [];
|
|
1138
|
+
if (this.baseSystemPrompt) {
|
|
1139
|
+
parts.push(this.baseSystemPrompt);
|
|
1140
|
+
}
|
|
1141
|
+
if (startHooksInstruction) {
|
|
1142
|
+
parts.push(startHooksInstruction);
|
|
1143
|
+
}
|
|
1144
|
+
if (customInstructions) {
|
|
1145
|
+
parts.push(customInstructions);
|
|
1146
|
+
}
|
|
1147
|
+
const combinedInstructions = parts.length > 0 ? parts.join("\n\n") : void 0;
|
|
1148
|
+
if (combinedInstructions) {
|
|
1149
|
+
message = combinedInstructions + "\n\n\n" + wrapInTag(message, CODEX_USER_INSTRUCTION_TAG);
|
|
1111
1150
|
} else {
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
const startHooksInstruction = this.getStartHooksInstruction();
|
|
1119
|
-
const parts = [];
|
|
1120
|
-
if (this.baseSystemPrompt) {
|
|
1121
|
-
parts.push(this.baseSystemPrompt);
|
|
1122
|
-
}
|
|
1123
|
-
if (startHooksInstruction) {
|
|
1124
|
-
parts.push(startHooksInstruction);
|
|
1125
|
-
}
|
|
1126
|
-
if (customInstructions) {
|
|
1127
|
-
parts.push(customInstructions);
|
|
1128
|
-
}
|
|
1129
|
-
const combinedInstructions = parts.length > 0 ? parts.join("\n\n") : void 0;
|
|
1130
|
-
if (combinedInstructions) {
|
|
1131
|
-
message = combinedInstructions + "\n" + message;
|
|
1132
|
-
}
|
|
1133
|
-
const { events: events2 } = await this.currentThread.runStreamed("Hello");
|
|
1134
|
-
for await (const event of events2) {
|
|
1135
|
-
if (event.type === "thread.started") {
|
|
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;
|
|
1151
|
+
message = wrapInTag(message, CODEX_USER_INSTRUCTION_TAG);
|
|
1152
|
+
}
|
|
1153
|
+
const { events: events2 } = await this.currentThread.runStreamed(wrapInTag("Hello", CODEX_USER_INSTRUCTION_TAG));
|
|
1154
|
+
for await (const event of events2) {
|
|
1155
|
+
if (event.type === "thread.started") {
|
|
1156
|
+
this.currentThreadId = event.thread_id;
|
|
1143
1157
|
await saveEngineState({ codexThreadId: this.currentThreadId });
|
|
1144
|
-
console.log(`[CodexManager] Captured and persisted thread ID
|
|
1158
|
+
console.log(`[CodexManager] Captured and persisted thread ID: ${this.currentThreadId}`);
|
|
1145
1159
|
}
|
|
1146
1160
|
}
|
|
1161
|
+
if (!this.currentThreadId && this.currentThread.id) {
|
|
1162
|
+
this.currentThreadId = this.currentThread.id;
|
|
1163
|
+
await saveEngineState({ codexThreadId: this.currentThreadId });
|
|
1164
|
+
console.log(`[CodexManager] Captured and persisted thread ID from thread.id: ${this.currentThreadId}`);
|
|
1165
|
+
}
|
|
1147
1166
|
}
|
|
1167
|
+
const wrappedMessage = this.currentThreadId && !message.includes(`<${CODEX_USER_INSTRUCTION_TAG}>`) ? wrapInTag(message, CODEX_USER_INSTRUCTION_TAG) : message;
|
|
1148
1168
|
let input;
|
|
1149
1169
|
if (tempImagePaths.length > 0) {
|
|
1150
1170
|
const inputItems = [
|
|
1151
|
-
{ type: "text", text:
|
|
1171
|
+
{ type: "text", text: wrappedMessage },
|
|
1152
1172
|
...tempImagePaths.map((path5) => ({ type: "local_image", path: path5 }))
|
|
1153
1173
|
];
|
|
1154
1174
|
input = inputItems;
|
|
1155
1175
|
} else {
|
|
1156
|
-
input =
|
|
1176
|
+
input = wrappedMessage;
|
|
1157
1177
|
}
|
|
1158
1178
|
const { events } = await this.currentThread.runStreamed(input);
|
|
1159
1179
|
let latestThoughtEvent = null;
|