negotium 0.2.2 → 0.2.4
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/agent-helpers.js +3117 -2915
- package/dist/agent-helpers.js.map +38 -37
- package/dist/background-bash.js.map +1 -1
- package/dist/browser-runtime.js +137 -21
- package/dist/browser-runtime.js.map +10 -9
- package/dist/{chunk-kc5kmr95.js → chunk-1s9ryz8g.js} +1195 -21
- package/dist/chunk-1s9ryz8g.js.map +35 -0
- package/dist/hosted-agent.js +60 -48
- package/dist/hosted-agent.js.map +10 -10
- package/dist/main.js +3038 -3357
- package/dist/main.js.map +35 -35
- package/dist/mcp-factories.js +6227 -6021
- package/dist/mcp-factories.js.map +40 -39
- package/dist/prompts.js.map +1 -1
- package/dist/query-runtime.js +22 -2
- package/dist/query-runtime.js.map +4 -4
- package/dist/registry.js +169 -213
- package/dist/registry.js.map +8 -9
- package/dist/rollout.js +1 -1
- package/dist/runtime/src/agents/codex-app-server.ts +136 -0
- package/dist/runtime/src/agents/codex-native-multi-agent.ts +1 -1
- package/dist/runtime/src/agents/codex-provider.ts +21 -11
- package/dist/runtime/src/agents/codex-registry.ts +9 -17
- package/dist/runtime/src/agents/contracts.ts +2 -0
- package/dist/runtime/src/agents/execution-host.ts +6 -0
- package/dist/runtime/src/agents/fork.ts +24 -18
- package/dist/runtime/src/agents/idle-archiver.ts +7 -2
- package/dist/runtime/src/agents/index.ts +2 -1
- package/dist/runtime/src/agents/maestro-registry.ts +26 -7
- package/dist/runtime/src/agents/memory-archive-policy.ts +20 -0
- package/dist/runtime/src/agents/rollout/codex.ts +6 -5
- package/dist/runtime/src/agents/rollout/shared.ts +3 -5
- package/dist/runtime/src/mcp/factories/session-comm.ts +12 -0
- package/dist/runtime/src/mcp/session-comm/default-host.ts +16 -0
- package/dist/runtime/src/mcp/session-comm/server.ts +25 -0
- package/dist/runtime/src/platform/config.ts +4 -1
- package/dist/runtime/src/platform/playwright/manager.ts +57 -1
- package/dist/runtime/src/platform/playwright/profile-management.ts +33 -0
- package/dist/runtime/src/platform/playwright/public-runtime.ts +5 -0
- package/dist/runtime/src/platform/playwright/vault-broker.ts +9 -10
- package/dist/runtime/src/storage/browser-profiles.ts +35 -10
- package/dist/runtime/src/storage/storage-host.ts +31 -5
- package/dist/runtime/src/storage/vault.ts +30 -2
- package/dist/runtime/src/topics/derive.ts +38 -2
- package/dist/runtime/src/topics/lifecycle.ts +12 -2
- package/dist/runtime/src/version.ts +1 -1
- package/dist/runtime-helpers.js +22 -2
- package/dist/runtime-helpers.js.map +4 -4
- package/dist/storage.js +22 -2
- package/dist/storage.js.map +4 -4
- package/dist/types/packages/core/src/agents/codex-app-server.d.ts +13 -0
- package/dist/types/packages/core/src/agents/codex-native-multi-agent.d.ts +1 -0
- package/dist/types/packages/core/src/agents/contracts.d.ts +2 -0
- package/dist/types/packages/core/src/agents/execution-host.d.ts +2 -0
- package/dist/types/packages/core/src/agents/fork.d.ts +8 -7
- package/dist/types/packages/core/src/agents/memory-archive-policy.d.ts +10 -0
- package/dist/types/packages/core/src/agents/rollout/codex.d.ts +4 -2
- package/dist/types/packages/core/src/mcp/factories/session-comm.d.ts +1 -0
- package/dist/types/packages/core/src/platform/playwright/manager.d.ts +15 -0
- package/dist/types/packages/core/src/platform/playwright/profile-management.d.ts +8 -0
- package/dist/types/packages/core/src/platform/playwright/public-runtime.d.ts +2 -1
- package/dist/types/packages/core/src/storage/browser-profiles.d.ts +3 -1
- package/dist/types/packages/core/src/storage/storage-host.d.ts +1 -0
- package/dist/types/packages/core/src/storage/vault.d.ts +8 -0
- package/dist/types/packages/core/src/version.d.ts +1 -1
- package/dist/vault.js +19 -3
- package/dist/vault.js.map +4 -4
- package/package.json +2 -2
- package/dist/chunk-kc5kmr95.js.map +0 -19
- package/dist/runtime/src/migration/single-user.ts +0 -805
package/dist/registry.js
CHANGED
|
@@ -11,10 +11,12 @@ import {
|
|
|
11
11
|
encodeClaudeCwd,
|
|
12
12
|
ensureCwdExists,
|
|
13
13
|
extractChatPairs,
|
|
14
|
+
hostedCodexHomePath,
|
|
15
|
+
latestCodexRolloutPath,
|
|
14
16
|
logger,
|
|
15
17
|
writeClaudeRollout,
|
|
16
18
|
writeCodexRollout
|
|
17
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-1s9ryz8g.js";
|
|
18
20
|
|
|
19
21
|
// ../../packages/core/src/agents/claude-registry.ts
|
|
20
22
|
import { existsSync, mkdirSync, readdirSync, renameSync, unlinkSync } from "fs";
|
|
@@ -98,209 +100,155 @@ var claudeRegistryOperations = {
|
|
|
98
100
|
|
|
99
101
|
// ../../packages/core/src/agents/codex-registry.ts
|
|
100
102
|
import { existsSync as existsSync3, unlinkSync as unlinkSync3 } from "fs";
|
|
101
|
-
import {
|
|
102
|
-
import { join as join4 } from "path";
|
|
103
|
+
import { join as join3 } from "path";
|
|
103
104
|
|
|
104
|
-
// ../../packages/core/src/
|
|
105
|
+
// ../../packages/core/src/agents/codex-app-server.ts
|
|
106
|
+
import { spawn } from "child_process";
|
|
107
|
+
|
|
108
|
+
// ../../packages/core/src/agents/codex-native-multi-agent.ts
|
|
105
109
|
import {
|
|
110
|
+
chmodSync,
|
|
111
|
+
copyFileSync,
|
|
106
112
|
existsSync as existsSync2,
|
|
107
|
-
|
|
113
|
+
mkdtempSync,
|
|
108
114
|
readFileSync,
|
|
109
115
|
renameSync as renameSync2,
|
|
116
|
+
rmSync,
|
|
110
117
|
unlinkSync as unlinkSync2,
|
|
111
118
|
writeFileSync
|
|
112
119
|
} from "fs";
|
|
113
|
-
import {
|
|
114
|
-
|
|
115
|
-
// ../../packages/core/src/security/sanitize.ts
|
|
116
|
-
function sanitizeTopicName(name, lowercase = false) {
|
|
117
|
-
const safe = name.replace(/[^a-zA-Z0-9\uAC00-\uD7A3_-]/g, "_") || "_";
|
|
118
|
-
return lowercase ? safe.toLowerCase() : safe;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// ../../packages/core/src/storage/storage-host.ts
|
|
122
|
-
import { mkdirSync as mkdirSync2 } from "fs";
|
|
123
|
-
import { homedir as homedir2 } from "os";
|
|
124
|
-
import { dirname, join as join2, resolve } from "path";
|
|
120
|
+
import { createRequire } from "module";
|
|
121
|
+
import { dirname, join as join2 } from "path";
|
|
125
122
|
|
|
126
|
-
// ../../packages/core/src/
|
|
127
|
-
var
|
|
128
|
-
var Database;
|
|
129
|
-
if (isBun) {
|
|
130
|
-
({ Database } = await import("bun:sqlite"));
|
|
131
|
-
} else {
|
|
132
|
-
const nodeSqliteSpecifier = ["node", "sqlite"].join(":");
|
|
133
|
-
const { DatabaseSync } = await import(nodeSqliteSpecifier);
|
|
123
|
+
// ../../packages/core/src/version.ts
|
|
124
|
+
var NEGOTIUM_VERSION = "0.2.4";
|
|
134
125
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return this.#db.prepare(sql);
|
|
145
|
-
}
|
|
146
|
-
exec(sql) {
|
|
147
|
-
this.#db.exec(sql);
|
|
148
|
-
}
|
|
149
|
-
run(sql, ...params) {
|
|
150
|
-
return this.#db.prepare(sql).run(...params);
|
|
151
|
-
}
|
|
152
|
-
transaction(fn) {
|
|
153
|
-
const run = (begin) => (...args) => {
|
|
154
|
-
this.#db.exec(begin);
|
|
155
|
-
try {
|
|
156
|
-
const result = fn(...args);
|
|
157
|
-
this.#db.exec("COMMIT");
|
|
158
|
-
return result;
|
|
159
|
-
} catch (err) {
|
|
160
|
-
this.#db.exec("ROLLBACK");
|
|
161
|
-
throw err;
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
const tx = run("BEGIN");
|
|
165
|
-
tx.deferred = run("BEGIN DEFERRED");
|
|
166
|
-
tx.immediate = run("BEGIN IMMEDIATE");
|
|
167
|
-
tx.exclusive = run("BEGIN EXCLUSIVE");
|
|
168
|
-
return tx;
|
|
169
|
-
}
|
|
170
|
-
close() {
|
|
171
|
-
this.#db.close();
|
|
172
|
-
}
|
|
126
|
+
// ../../packages/core/src/agents/codex-native-multi-agent.ts
|
|
127
|
+
var moduleRequire = createRequire(import.meta.url);
|
|
128
|
+
var codexSdkPackagePath = moduleRequire.resolve("@openai/codex-sdk/package.json");
|
|
129
|
+
var codexSdkRequire = createRequire(codexSdkPackagePath);
|
|
130
|
+
var bundledCodexPackagePath = codexSdkRequire.resolve("@openai/codex/package.json");
|
|
131
|
+
function readPackageVersion(packageJsonPath) {
|
|
132
|
+
const parsed = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
133
|
+
if (typeof parsed.version !== "string" || !parsed.version.trim()) {
|
|
134
|
+
throw new Error(`Codex package has no valid version: ${packageJsonPath}`);
|
|
173
135
|
}
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// ../../packages/core/src/storage/storage-host.ts
|
|
178
|
-
var configuredHost = {};
|
|
179
|
-
var fallbackDatabase = null;
|
|
180
|
-
var fallbackDatabasePath = null;
|
|
181
|
-
var schemaInitializers = [];
|
|
182
|
-
var initializedSchemas = new WeakMap;
|
|
183
|
-
var initializingDatabases = new WeakSet;
|
|
184
|
-
function envPath(name, fallback) {
|
|
185
|
-
const value = process.env[name]?.trim();
|
|
186
|
-
return resolve(value || fallback);
|
|
136
|
+
return parsed.version;
|
|
187
137
|
}
|
|
188
|
-
|
|
189
|
-
|
|
138
|
+
var BUNDLED_CODEX_VERSION = readPackageVersion(bundledCodexPackagePath);
|
|
139
|
+
var SAFE_BUNDLED_CODEX_VERSION = BUNDLED_CODEX_VERSION.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
140
|
+
var NEGOTIUM_MODEL_CACHE = `negotium-models-cache-${SAFE_BUNDLED_CODEX_VERSION}.json`;
|
|
141
|
+
var NEGOTIUM_MODEL_CATALOG = `negotium-model-catalog-${SAFE_BUNDLED_CODEX_VERSION}.json`;
|
|
142
|
+
function codexCliScriptPath() {
|
|
143
|
+
return join2(dirname(bundledCodexPackagePath), "bin", "codex.js");
|
|
190
144
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
145
|
+
|
|
146
|
+
// ../../packages/core/src/agents/codex-app-server.ts
|
|
147
|
+
function createCodexAppServerForker(host) {
|
|
148
|
+
return async (parentThreadId) => {
|
|
149
|
+
const child = host.spawnServer();
|
|
150
|
+
return await new Promise((resolve, reject) => {
|
|
151
|
+
let settled = false;
|
|
152
|
+
let stdoutBuffer = "";
|
|
153
|
+
let stderr = "";
|
|
154
|
+
const timer = setTimeout(() => finish(new Error("Codex thread fork timed out")), host.timeoutMs);
|
|
155
|
+
const finish = (error, result) => {
|
|
156
|
+
if (settled)
|
|
157
|
+
return;
|
|
158
|
+
settled = true;
|
|
159
|
+
clearTimeout(timer);
|
|
160
|
+
try {
|
|
161
|
+
child.stdin.end();
|
|
162
|
+
child.kill();
|
|
163
|
+
} catch {}
|
|
164
|
+
if (error)
|
|
165
|
+
reject(error);
|
|
166
|
+
else if (result)
|
|
167
|
+
resolve(result);
|
|
168
|
+
else
|
|
169
|
+
reject(new Error("Codex thread fork returned no result"));
|
|
170
|
+
};
|
|
171
|
+
const send = (message) => {
|
|
172
|
+
child.stdin.write(`${JSON.stringify(message)}
|
|
173
|
+
`);
|
|
174
|
+
};
|
|
175
|
+
child.stderr.on("data", (chunk) => {
|
|
176
|
+
if (stderr.length < 8192)
|
|
177
|
+
stderr += String(chunk);
|
|
178
|
+
});
|
|
179
|
+
child.on("error", (error) => finish(error));
|
|
180
|
+
child.on("exit", (code, signal) => {
|
|
181
|
+
if (settled)
|
|
182
|
+
return;
|
|
183
|
+
const detail = signal ? `signal ${signal}` : `code ${code ?? 1}`;
|
|
184
|
+
finish(new Error(`Codex app server exited with ${detail}${stderr.trim() ? `: ${stderr.trim()}` : ""}`));
|
|
185
|
+
});
|
|
186
|
+
child.stdout.on("data", (chunk) => {
|
|
187
|
+
stdoutBuffer += String(chunk);
|
|
188
|
+
for (;; ) {
|
|
189
|
+
const newline = stdoutBuffer.indexOf(`
|
|
190
|
+
`);
|
|
191
|
+
if (newline < 0)
|
|
192
|
+
break;
|
|
193
|
+
const line = stdoutBuffer.slice(0, newline);
|
|
194
|
+
stdoutBuffer = stdoutBuffer.slice(newline + 1);
|
|
195
|
+
let message;
|
|
196
|
+
try {
|
|
197
|
+
message = JSON.parse(line);
|
|
198
|
+
} catch {
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
if (message.id === 1) {
|
|
202
|
+
if (message.error) {
|
|
203
|
+
finish(new Error(String(message.error.message || "Codex initialization failed")));
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
send({ method: "initialized" });
|
|
207
|
+
send({ id: 2, method: "thread/fork", params: { threadId: parentThreadId } });
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
if (message.id !== 2)
|
|
211
|
+
continue;
|
|
212
|
+
if (message.error) {
|
|
213
|
+
finish(new Error(String(message.error.message || "Codex thread fork failed")));
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const forkId = message.result?.thread?.id;
|
|
217
|
+
if (typeof forkId !== "string" || !forkId) {
|
|
218
|
+
finish(new Error("Codex thread fork returned no thread id"));
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const rolloutPath = host.findRolloutPath(forkId);
|
|
222
|
+
if (!rolloutPath) {
|
|
223
|
+
finish(new Error(`Codex thread fork rollout was not found for ${forkId}`));
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
finish(undefined, { forkId, rolloutPath });
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
send({
|
|
231
|
+
id: 1,
|
|
232
|
+
method: "initialize",
|
|
233
|
+
params: {
|
|
234
|
+
clientInfo: { name: "negotium", version: NEGOTIUM_VERSION }
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
};
|
|
248
239
|
}
|
|
249
|
-
var
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
240
|
+
var forkCodexThread = createCodexAppServerForker({
|
|
241
|
+
spawnServer() {
|
|
242
|
+
return spawn(process.execPath, [codexCliScriptPath(), "app-server", "--stdio"], {
|
|
243
|
+
env: { ...process.env, CODEX_HOME: hostedCodexHomePath() },
|
|
244
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
245
|
+
});
|
|
255
246
|
},
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
ensureStorageSchemas(database);
|
|
259
|
-
return Reflect.set(database, property, value, database);
|
|
260
|
-
}
|
|
247
|
+
findRolloutPath: latestCodexRolloutPath,
|
|
248
|
+
timeoutMs: 15000
|
|
261
249
|
});
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
function conversationDir(_userId) {
|
|
265
|
-
return join3(resolveStorageDataDir(), "conversations");
|
|
266
|
-
}
|
|
267
|
-
function topicFilename(topicName) {
|
|
268
|
-
const t = sanitizeTopicName(topicName, true);
|
|
269
|
-
return `${t}.jsonl`;
|
|
270
|
-
}
|
|
271
|
-
function getConversationPath(userId, topicName) {
|
|
272
|
-
return join3(conversationDir(userId), topicFilename(topicName));
|
|
273
|
-
}
|
|
274
|
-
function getActiveConversationPath(userId, topicName) {
|
|
275
|
-
const rawPath = getConversationPath(userId, topicName);
|
|
276
|
-
return rawPath.endsWith(".jsonl") ? `${rawPath.slice(0, -".jsonl".length)}.active.jsonl` : `${rawPath}.active`;
|
|
277
|
-
}
|
|
278
|
-
function readConversationPath(path) {
|
|
279
|
-
const out = [];
|
|
280
|
-
if (!existsSync2(path))
|
|
281
|
-
return out;
|
|
282
|
-
let raw;
|
|
283
|
-
try {
|
|
284
|
-
raw = readFileSync(path, "utf8");
|
|
285
|
-
} catch (err) {
|
|
286
|
-
logger.warn({ err, path }, "readConversation: read failed");
|
|
287
|
-
return out;
|
|
288
|
-
}
|
|
289
|
-
for (const line of raw.split(`
|
|
290
|
-
`)) {
|
|
291
|
-
if (!line.trim())
|
|
292
|
-
continue;
|
|
293
|
-
try {
|
|
294
|
-
out.push(JSON.parse(line));
|
|
295
|
-
} catch (err) {
|
|
296
|
-
logger.warn({ err, line: line.slice(0, 200) }, "readConversation: malformed JSONL line skipped");
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
return out;
|
|
300
|
-
}
|
|
301
|
-
function readConversation(userId, topicName) {
|
|
302
|
-
const activePath = getActiveConversationPath(userId, topicName);
|
|
303
|
-
return readConversationPath(existsSync2(activePath) ? activePath : getConversationPath(userId, topicName));
|
|
250
|
+
async function forkCodexSession(parentThreadId) {
|
|
251
|
+
return await forkCodexThread(parentThreadId);
|
|
304
252
|
}
|
|
305
253
|
|
|
306
254
|
// ../../packages/core/src/agents/codex-registry.ts
|
|
@@ -333,20 +281,13 @@ var codexRegistryOperations = {
|
|
|
333
281
|
});
|
|
334
282
|
return { sessionId: threadId, rolloutPath };
|
|
335
283
|
},
|
|
336
|
-
async forkSession({
|
|
337
|
-
|
|
338
|
-
const { threadId, rolloutPath } = writeCodexRollout({
|
|
339
|
-
cwd,
|
|
340
|
-
entries,
|
|
341
|
-
model: model ?? codexRegistry.defaultModel,
|
|
342
|
-
...effort ? { effort } : {}
|
|
343
|
-
});
|
|
344
|
-
return { forkId: threadId, rolloutPath };
|
|
284
|
+
async forkSession({ parentSessionId }) {
|
|
285
|
+
return await forkCodexSession(parentSessionId);
|
|
345
286
|
},
|
|
346
287
|
async cleanupRollouts({ sessionIds }) {
|
|
347
288
|
if (sessionIds.length === 0)
|
|
348
289
|
return;
|
|
349
|
-
const sessionsDir =
|
|
290
|
+
const sessionsDir = join3(hostedCodexHomePath(), "sessions");
|
|
350
291
|
if (!existsSync3(sessionsDir))
|
|
351
292
|
return;
|
|
352
293
|
const failures = [];
|
|
@@ -354,7 +295,7 @@ var codexRegistryOperations = {
|
|
|
354
295
|
try {
|
|
355
296
|
const glob = new Bun.Glob(`**/rollout-*-${tid}.jsonl`);
|
|
356
297
|
for await (const rel of glob.scan({ cwd: sessionsDir, onlyFiles: true })) {
|
|
357
|
-
const path =
|
|
298
|
+
const path = join3(sessionsDir, rel);
|
|
358
299
|
try {
|
|
359
300
|
unlinkSync3(path);
|
|
360
301
|
} catch (e) {
|
|
@@ -377,9 +318,9 @@ var codexRegistryOperations = {
|
|
|
377
318
|
|
|
378
319
|
// ../../packages/core/src/agents/maestro-registry.ts
|
|
379
320
|
import { randomUUID } from "crypto";
|
|
380
|
-
import { existsSync as existsSync4, mkdirSync as
|
|
381
|
-
import { homedir as
|
|
382
|
-
import { join as
|
|
321
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
322
|
+
import { homedir as homedir2 } from "os";
|
|
323
|
+
import { join as join4, resolve } from "path";
|
|
383
324
|
var ALIAS_MAP2 = {
|
|
384
325
|
"deepseek-pro": "deepseek-v4-pro",
|
|
385
326
|
kimi: "kimi-k3",
|
|
@@ -407,13 +348,13 @@ var maestroRegistry = {
|
|
|
407
348
|
}
|
|
408
349
|
};
|
|
409
350
|
function maestroSessionsDir() {
|
|
410
|
-
return
|
|
351
|
+
return join4(process.env.MAESTRO_DATA_DIR ? resolve(process.env.MAESTRO_DATA_DIR) : join4(homedir2(), ".maestro"), "sessions");
|
|
411
352
|
}
|
|
412
353
|
function maestroSessionPath(sessionId) {
|
|
413
|
-
return
|
|
354
|
+
return join4(maestroSessionsDir(), `${sessionId}.jsonl`);
|
|
414
355
|
}
|
|
415
356
|
function maestroActiveSessionPath(sessionId) {
|
|
416
|
-
return
|
|
357
|
+
return join4(maestroSessionsDir(), `${sessionId}.active.jsonl`);
|
|
417
358
|
}
|
|
418
359
|
function existingCreatedAt(path) {
|
|
419
360
|
if (!existsSync4(path))
|
|
@@ -432,7 +373,7 @@ function writeRollout(options) {
|
|
|
432
373
|
assertUuidLike("sessionId", sessionId);
|
|
433
374
|
ensureCwdExists(options.cwd);
|
|
434
375
|
const path = maestroSessionPath(sessionId);
|
|
435
|
-
|
|
376
|
+
mkdirSync2(maestroSessionsDir(), { recursive: true });
|
|
436
377
|
const messages = extractChatPairs(options.entries).flatMap((pair) => [
|
|
437
378
|
{ role: "user", content: pair.userText },
|
|
438
379
|
{ role: "assistant", content: pair.assistantText }
|
|
@@ -443,7 +384,7 @@ function writeRollout(options) {
|
|
|
443
384
|
version: 1,
|
|
444
385
|
cwd: options.cwd,
|
|
445
386
|
createdAt: existingCreatedAt(path) ?? new Date().toISOString(),
|
|
446
|
-
sdkVersion: "0.
|
|
387
|
+
sdkVersion: "0.2.0"
|
|
447
388
|
}
|
|
448
389
|
},
|
|
449
390
|
...messages
|
|
@@ -460,13 +401,28 @@ var maestroRegistryOperations = {
|
|
|
460
401
|
return writeRollout(options);
|
|
461
402
|
},
|
|
462
403
|
async forkSession(options) {
|
|
463
|
-
const
|
|
404
|
+
const { deleteMaestroSession, forkSessionAt, loadRawMaestroSession } = await import("maestro-agent-sdk");
|
|
405
|
+
const parentMessages = loadRawMaestroSession(options.parentSessionId);
|
|
406
|
+
if (!parentMessages) {
|
|
407
|
+
throw new Error(`Maestro parent session not found: ${options.parentSessionId}`);
|
|
408
|
+
}
|
|
409
|
+
const parentHasActiveProjection = existsSync4(maestroActiveSessionPath(options.parentSessionId));
|
|
410
|
+
const fork = forkSessionAt({
|
|
411
|
+
parentSessionId: options.parentSessionId,
|
|
412
|
+
messageIndex: parentMessages.length,
|
|
464
413
|
cwd: options.cwd,
|
|
465
|
-
|
|
466
|
-
...options.model ? { model: options.model } : {},
|
|
467
|
-
...options.effort ? { effort: options.effort } : {}
|
|
414
|
+
userId: String(options.userId)
|
|
468
415
|
});
|
|
469
|
-
|
|
416
|
+
if (parentHasActiveProjection && !fork.activeProjectionForked) {
|
|
417
|
+
deleteMaestroSession(fork.sessionId);
|
|
418
|
+
throw new Error(`Maestro active projection could not be forked: ${options.parentSessionId}`);
|
|
419
|
+
}
|
|
420
|
+
const activePath = maestroActiveSessionPath(fork.sessionId);
|
|
421
|
+
return {
|
|
422
|
+
forkId: fork.sessionId,
|
|
423
|
+
rolloutPath: fork.rolloutPath,
|
|
424
|
+
...existsSync4(activePath) ? { cleanupPaths: [activePath] } : {}
|
|
425
|
+
};
|
|
470
426
|
},
|
|
471
427
|
async cleanupRollouts(options) {
|
|
472
428
|
const { deleteMaestroSession } = await import("maestro-agent-sdk");
|
|
@@ -518,4 +474,4 @@ export {
|
|
|
518
474
|
getRegistry2 as getRegistry
|
|
519
475
|
};
|
|
520
476
|
|
|
521
|
-
//# debugId=
|
|
477
|
+
//# debugId=2C2992ACF93ADB3E64756E2164756E21
|