repoburg 1.3.317 → 1.3.319
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/agent-pane/backend/dist/index.js +487 -162
- package/agent-pane/backend/dist/server.js +487 -162
- package/agent-pane/frontend/dist/assets/{TerminalView-D3fkOngy.js → TerminalView-D5Hg3Fzf.js} +1 -1
- package/agent-pane/frontend/dist/assets/index-C1m0abtH.css +1 -0
- package/agent-pane/frontend/dist/assets/index-Cckb2tlY.js +852 -0
- package/agent-pane/frontend/dist/index.html +2 -2
- package/backend/dist/src/application-state/application-state.service.d.ts +5 -0
- package/backend/dist/src/application-state/application-state.service.js +18 -0
- package/backend/dist/src/application-state/application-state.service.js.map +1 -1
- package/backend/dist/src/core-entities/enums.d.ts +1 -0
- package/backend/dist/src/core-entities/enums.js +1 -0
- package/backend/dist/src/core-entities/enums.js.map +1 -1
- package/backend/dist/src/global-config/global-config.service.d.ts +1 -0
- package/backend/dist/src/global-config/global-config.service.js +15 -1
- package/backend/dist/src/global-config/global-config.service.js.map +1 -1
- package/backend/dist/src/llm-provider/alibaba-llm.provider.d.ts +18 -2
- package/backend/dist/src/llm-provider/alibaba-llm.provider.js +155 -17
- package/backend/dist/src/llm-provider/alibaba-llm.provider.js.map +1 -1
- package/backend/dist/src/llm-provider/credential-check.d.ts +3 -0
- package/backend/dist/src/llm-provider/credential-check.js +27 -0
- package/backend/dist/src/llm-provider/credential-check.js.map +1 -0
- package/backend/dist/src/llm-provider/dto/set-inference-credentials.dto.d.ts +5 -0
- package/backend/dist/src/llm-provider/dto/set-inference-credentials.dto.js +46 -0
- package/backend/dist/src/llm-provider/dto/set-inference-credentials.dto.js.map +1 -0
- package/backend/dist/src/llm-provider/inference-credentials.service.d.ts +24 -0
- package/backend/dist/src/llm-provider/inference-credentials.service.js +120 -0
- package/backend/dist/src/llm-provider/inference-credentials.service.js.map +1 -0
- package/backend/dist/src/llm-provider/inference-registry.d.ts +15 -0
- package/backend/dist/src/llm-provider/inference-registry.js +68 -0
- package/backend/dist/src/llm-provider/inference-registry.js.map +1 -0
- package/backend/dist/src/llm-provider/llm-provider.controller.d.ts +15 -1
- package/backend/dist/src/llm-provider/llm-provider.controller.js +75 -3
- package/backend/dist/src/llm-provider/llm-provider.controller.js.map +1 -1
- package/backend/dist/src/llm-provider/llm-provider.interface.d.ts +34 -1
- package/backend/dist/src/llm-provider/llm-provider.interface.js +8 -1
- package/backend/dist/src/llm-provider/llm-provider.interface.js.map +1 -1
- package/backend/dist/src/llm-provider/llm-provider.module.js +5 -1
- package/backend/dist/src/llm-provider/llm-provider.module.js.map +1 -1
- package/backend/dist/src/llm-provider/ollama-llm.provider.d.ts +14 -6
- package/backend/dist/src/llm-provider/ollama-llm.provider.js +208 -80
- package/backend/dist/src/llm-provider/ollama-llm.provider.js.map +1 -1
- package/backend/dist/src/llm-provider/openai-llm.provider.d.ts +7 -2
- package/backend/dist/src/llm-provider/openai-llm.provider.js +50 -8
- package/backend/dist/src/llm-provider/openai-llm.provider.js.map +1 -1
- package/backend/dist/src/llm-provider/openrouter-llm.provider.d.ts +21 -2
- package/backend/dist/src/llm-provider/openrouter-llm.provider.js +124 -14
- package/backend/dist/src/llm-provider/openrouter-llm.provider.js.map +1 -1
- package/backend/dist/src/llm-provider/proxy-llm.provider.d.ts +4 -11
- package/backend/dist/src/llm-provider/proxy-llm.provider.js +17 -47
- package/backend/dist/src/llm-provider/proxy-llm.provider.js.map +1 -1
- package/backend/dist/src/llm-provider/reasoning.d.ts +9 -0
- package/backend/dist/src/llm-provider/reasoning.js +73 -0
- package/backend/dist/src/llm-provider/reasoning.js.map +1 -0
- package/backend/dist/src/llm-provider/zai-llm.provider.d.ts +24 -2
- package/backend/dist/src/llm-provider/zai-llm.provider.js +134 -17
- package/backend/dist/src/llm-provider/zai-llm.provider.js.map +1 -1
- package/backend/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/tabtape/extension/dist/build-info.json +3 -3
- package/tabtape/extension/dist/manifest.json +1 -1
- package/tabtape/ui/dist/build-info.json +3 -3
- package/agent-pane/frontend/dist/assets/index-Bb9z3drP.js +0 -852
- package/agent-pane/frontend/dist/assets/index-nEHdBY3j.css +0 -1
|
@@ -11485,7 +11485,7 @@ var require_reply = __commonJS({
|
|
|
11485
11485
|
}
|
|
11486
11486
|
return serialize2;
|
|
11487
11487
|
};
|
|
11488
|
-
Reply.prototype.compileSerializationSchema = function(schema,
|
|
11488
|
+
Reply.prototype.compileSerializationSchema = function(schema, httpStatus2 = null, contentType = null) {
|
|
11489
11489
|
const { request } = this;
|
|
11490
11490
|
const { method, url: url2 } = request;
|
|
11491
11491
|
if (this[kRouteContext][kReplyCacheSerializeFns]?.has(schema)) {
|
|
@@ -11498,7 +11498,7 @@ var require_reply = __commonJS({
|
|
|
11498
11498
|
schema,
|
|
11499
11499
|
method,
|
|
11500
11500
|
url: url2,
|
|
11501
|
-
httpStatus,
|
|
11501
|
+
httpStatus: httpStatus2,
|
|
11502
11502
|
contentType
|
|
11503
11503
|
});
|
|
11504
11504
|
if (this[kRouteContext][kReplyCacheSerializeFns] == null) {
|
|
@@ -11507,26 +11507,26 @@ var require_reply = __commonJS({
|
|
|
11507
11507
|
this[kRouteContext][kReplyCacheSerializeFns].set(schema, serializeFn);
|
|
11508
11508
|
return serializeFn;
|
|
11509
11509
|
};
|
|
11510
|
-
Reply.prototype.serializeInput = function(input, schema,
|
|
11511
|
-
const possibleContentType =
|
|
11510
|
+
Reply.prototype.serializeInput = function(input, schema, httpStatus2, contentType) {
|
|
11511
|
+
const possibleContentType = httpStatus2;
|
|
11512
11512
|
let serialize2;
|
|
11513
|
-
|
|
11514
|
-
contentType =
|
|
11515
|
-
if (
|
|
11513
|
+
httpStatus2 = typeof schema === "string" || typeof schema === "number" ? schema : httpStatus2;
|
|
11514
|
+
contentType = httpStatus2 && possibleContentType !== httpStatus2 ? possibleContentType : contentType;
|
|
11515
|
+
if (httpStatus2 != null) {
|
|
11516
11516
|
if (contentType != null) {
|
|
11517
|
-
serialize2 = this[kRouteContext][kSchemaResponse]?.[
|
|
11517
|
+
serialize2 = this[kRouteContext][kSchemaResponse]?.[httpStatus2]?.[contentType];
|
|
11518
11518
|
} else {
|
|
11519
|
-
serialize2 = this[kRouteContext][kSchemaResponse]?.[
|
|
11519
|
+
serialize2 = this[kRouteContext][kSchemaResponse]?.[httpStatus2];
|
|
11520
11520
|
}
|
|
11521
11521
|
if (serialize2 == null) {
|
|
11522
|
-
if (contentType) throw new FST_ERR_MISSING_CONTENTTYPE_SERIALIZATION_FN(
|
|
11523
|
-
throw new FST_ERR_MISSING_SERIALIZATION_FN(
|
|
11522
|
+
if (contentType) throw new FST_ERR_MISSING_CONTENTTYPE_SERIALIZATION_FN(httpStatus2, contentType);
|
|
11523
|
+
throw new FST_ERR_MISSING_SERIALIZATION_FN(httpStatus2);
|
|
11524
11524
|
}
|
|
11525
11525
|
} else {
|
|
11526
11526
|
if (this[kRouteContext][kReplyCacheSerializeFns]?.has(schema)) {
|
|
11527
11527
|
serialize2 = this[kRouteContext][kReplyCacheSerializeFns].get(schema);
|
|
11528
11528
|
} else {
|
|
11529
|
-
serialize2 = this.compileSerializationSchema(schema,
|
|
11529
|
+
serialize2 = this.compileSerializationSchema(schema, httpStatus2, contentType);
|
|
11530
11530
|
}
|
|
11531
11531
|
}
|
|
11532
11532
|
return serialize2(input);
|
|
@@ -41180,6 +41180,9 @@ CREATE INDEX IF NOT EXISTS idx_workspaces_path ON workspaces(path);
|
|
|
41180
41180
|
if (!sessColumns.some((c) => c.name === "pre_rewind_thread_id")) {
|
|
41181
41181
|
database.exec("ALTER TABLE sessions ADD COLUMN pre_rewind_thread_id TEXT");
|
|
41182
41182
|
}
|
|
41183
|
+
if (!sessColumns.some((c) => c.name === "pre_rewind_turn_ids")) {
|
|
41184
|
+
database.exec("ALTER TABLE sessions ADD COLUMN pre_rewind_turn_ids TEXT");
|
|
41185
|
+
}
|
|
41183
41186
|
if (!sessColumns.some((c) => c.name === "context_usage")) {
|
|
41184
41187
|
database.exec("ALTER TABLE sessions ADD COLUMN context_usage TEXT");
|
|
41185
41188
|
}
|
|
@@ -41914,6 +41917,80 @@ function recomputeSessionRunning(db2, sessionId, idleStatus = "active", hasUnrev
|
|
|
41914
41917
|
}
|
|
41915
41918
|
}
|
|
41916
41919
|
|
|
41920
|
+
// src/routes/rewind-state.ts
|
|
41921
|
+
function forkPoint(db2, sessionId, target) {
|
|
41922
|
+
const row = db2.prepare(
|
|
41923
|
+
`SELECT external_turn_id FROM turns
|
|
41924
|
+
WHERE session_id = ? AND thread_id IS NULL AND external_turn_id IS NOT NULL
|
|
41925
|
+
AND status NOT IN ('pending', 'running') AND (id = ? OR created_at < ?)
|
|
41926
|
+
ORDER BY created_at DESC, rowid DESC LIMIT 1`
|
|
41927
|
+
).get(sessionId, target.id, target.created_at);
|
|
41928
|
+
return row?.external_turn_id ?? null;
|
|
41929
|
+
}
|
|
41930
|
+
function snapshotTurnIds(db2, sessionId) {
|
|
41931
|
+
const rows = db2.prepare("SELECT id, external_turn_id FROM turns WHERE session_id = ? AND thread_id IS NULL").all(sessionId);
|
|
41932
|
+
return JSON.stringify(Object.fromEntries(rows.map((r) => [r.id, r.external_turn_id])));
|
|
41933
|
+
}
|
|
41934
|
+
function restoreTurnIds(db2, sessionId, snapshot) {
|
|
41935
|
+
if (!snapshot) return;
|
|
41936
|
+
let ids;
|
|
41937
|
+
try {
|
|
41938
|
+
ids = JSON.parse(snapshot);
|
|
41939
|
+
} catch {
|
|
41940
|
+
return;
|
|
41941
|
+
}
|
|
41942
|
+
const update = db2.prepare("UPDATE turns SET external_turn_id = ? WHERE id = ? AND session_id = ?");
|
|
41943
|
+
for (const [turnId, externalId] of Object.entries(ids)) update.run(externalId, turnId, sessionId);
|
|
41944
|
+
}
|
|
41945
|
+
function applyTurnIdMap(db2, sessionId, map2, upToCreatedAt = null) {
|
|
41946
|
+
if (map2.size === 0) return;
|
|
41947
|
+
const rows = db2.prepare(
|
|
41948
|
+
`SELECT id, external_turn_id FROM turns
|
|
41949
|
+
WHERE session_id = ? AND thread_id IS NULL AND external_turn_id IS NOT NULL` + (upToCreatedAt ? " AND created_at <= ?" : "")
|
|
41950
|
+
).all(...upToCreatedAt ? [sessionId, upToCreatedAt] : [sessionId]);
|
|
41951
|
+
const update = db2.prepare("UPDATE turns SET external_turn_id = ? WHERE id = ?");
|
|
41952
|
+
for (const row of rows) {
|
|
41953
|
+
const mapped = map2.get(row.external_turn_id);
|
|
41954
|
+
if (mapped) update.run(mapped, row.id);
|
|
41955
|
+
}
|
|
41956
|
+
}
|
|
41957
|
+
function dropRewoundTurns(db2, sessionId) {
|
|
41958
|
+
const session = db2.prepare("SELECT rewound_at_turn_id FROM sessions WHERE id = ?").get(sessionId);
|
|
41959
|
+
if (!session?.rewound_at_turn_id) return null;
|
|
41960
|
+
const target = db2.prepare("SELECT created_at FROM turns WHERE id = ?").get(session.rewound_at_turn_id);
|
|
41961
|
+
let threadIds = [];
|
|
41962
|
+
db2.transaction(() => {
|
|
41963
|
+
if (target) {
|
|
41964
|
+
const hidden = "SELECT id FROM turns WHERE session_id = ? AND thread_id IS NULL AND created_at > ?";
|
|
41965
|
+
threadIds = db2.prepare(`SELECT id FROM discussion_threads WHERE session_id = ? AND turn_id IN (${hidden})`).all(sessionId, sessionId, target.created_at).map((r) => r.id);
|
|
41966
|
+
for (const threadId of threadIds) {
|
|
41967
|
+
db2.prepare("DELETE FROM items WHERE turn_id IN (SELECT id FROM turns WHERE thread_id = ?)").run(threadId);
|
|
41968
|
+
db2.prepare("DELETE FROM turns WHERE thread_id = ?").run(threadId);
|
|
41969
|
+
db2.prepare("DELETE FROM discussion_threads WHERE id = ?").run(threadId);
|
|
41970
|
+
}
|
|
41971
|
+
db2.prepare(`DELETE FROM items WHERE turn_id IN (${hidden})`).run(sessionId, target.created_at);
|
|
41972
|
+
db2.prepare("DELETE FROM turns WHERE session_id = ? AND thread_id IS NULL AND created_at > ?").run(
|
|
41973
|
+
sessionId,
|
|
41974
|
+
target.created_at
|
|
41975
|
+
);
|
|
41976
|
+
}
|
|
41977
|
+
db2.prepare(
|
|
41978
|
+
"UPDATE sessions SET rewound_at_turn_id = NULL, pre_rewind_turn_ids = NULL, updated_at = ? WHERE id = ?"
|
|
41979
|
+
).run((/* @__PURE__ */ new Date()).toISOString(), sessionId);
|
|
41980
|
+
})();
|
|
41981
|
+
return { threadIds };
|
|
41982
|
+
}
|
|
41983
|
+
function commitRewind(db2, sessionId, clearThreadBranch4) {
|
|
41984
|
+
const dropped = dropRewoundTurns(db2, sessionId);
|
|
41985
|
+
if (!dropped) return;
|
|
41986
|
+
const session = db2.prepare("SELECT * FROM sessions WHERE id = ?").get(sessionId);
|
|
41987
|
+
broadcast("session:updated", { session });
|
|
41988
|
+
for (const threadId of dropped.threadIds) {
|
|
41989
|
+
clearThreadBranch4?.(sessionId, threadId);
|
|
41990
|
+
broadcast("thread:deleted", { sessionId, threadId });
|
|
41991
|
+
}
|
|
41992
|
+
}
|
|
41993
|
+
|
|
41917
41994
|
// src/routes/session-touch.ts
|
|
41918
41995
|
function markSessionTouched(db2, sessionId) {
|
|
41919
41996
|
const { changes } = db2.prepare("UPDATE sessions SET user_touched = 1 WHERE id = ? AND user_touched = 0").run(sessionId);
|
|
@@ -41923,17 +42000,20 @@ function markSessionTouched(db2, sessionId) {
|
|
|
41923
42000
|
}
|
|
41924
42001
|
|
|
41925
42002
|
// src/routes/session-actions.ts
|
|
42003
|
+
function blankToNull(value) {
|
|
42004
|
+
return value === "" ? null : value;
|
|
42005
|
+
}
|
|
41926
42006
|
function createSession(db2, input) {
|
|
41927
42007
|
const {
|
|
41928
42008
|
title = null,
|
|
41929
42009
|
runtime_type = "codex",
|
|
41930
|
-
model = null,
|
|
41931
|
-
model_reasoning_effort = null,
|
|
41932
42010
|
cwd = null,
|
|
41933
42011
|
runtime_config = null,
|
|
41934
42012
|
origin_app_id = null,
|
|
41935
42013
|
origin_app_workspace = null
|
|
41936
42014
|
} = input;
|
|
42015
|
+
const model = blankToNull(input.model ?? null);
|
|
42016
|
+
const model_reasoning_effort = blankToNull(input.model_reasoning_effort ?? null);
|
|
41937
42017
|
const id = v4_default();
|
|
41938
42018
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
41939
42019
|
const maxOrder = db2.prepare("SELECT COALESCE(MAX(sort_order), 0) AS m FROM sessions WHERE cwd = ?").get(cwd ?? null);
|
|
@@ -41965,6 +42045,7 @@ var SessionBusyError = class extends Error {
|
|
|
41965
42045
|
function startTurn(db2, session, { prompt, attachments, originAppId }) {
|
|
41966
42046
|
if (isSessionBusy(db2, session, { mainOnly: true })) throw new SessionBusyError();
|
|
41967
42047
|
const provider = getProvider(session.runtime_type);
|
|
42048
|
+
commitRewind(db2, session.id, provider.clearThreadBranch?.bind(provider));
|
|
41968
42049
|
const turnId = v4_default();
|
|
41969
42050
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
41970
42051
|
const attachmentsJson = attachments && attachments.length > 0 ? JSON.stringify(attachments) : null;
|
|
@@ -42143,19 +42224,29 @@ async function registerSessionRoutes(fastify) {
|
|
|
42143
42224
|
}
|
|
42144
42225
|
}, async (request, reply) => {
|
|
42145
42226
|
const { id } = request.params;
|
|
42146
|
-
const
|
|
42227
|
+
const body = request.body || {};
|
|
42228
|
+
const { title, lifecycle, has_unreviewed, runtime_config, runtime_type, cwd, starred } = body;
|
|
42229
|
+
const model = body.model === void 0 ? void 0 : blankToNull(body.model);
|
|
42230
|
+
const model_reasoning_effort = body.model_reasoning_effort === void 0 ? void 0 : blankToNull(body.model_reasoning_effort);
|
|
42147
42231
|
const db2 = getDb();
|
|
42148
42232
|
const existing = db2.prepare("SELECT * FROM sessions WHERE id = ?").get(id);
|
|
42149
42233
|
if (!existing) {
|
|
42150
42234
|
return reply.code(404).send({ error: "Session not found" });
|
|
42151
42235
|
}
|
|
42152
|
-
|
|
42153
|
-
|
|
42236
|
+
const providerChanged = runtime_type !== void 0 && runtime_type !== existing.runtime_type;
|
|
42237
|
+
if (providerChanged) {
|
|
42238
|
+
if (existing.is_running) {
|
|
42239
|
+
return reply.code(409).send({ error: "Cannot switch provider while a turn is running" });
|
|
42240
|
+
}
|
|
42241
|
+
if (db2.prepare("SELECT 1 FROM turns WHERE session_id = ? LIMIT 1").get(id)) {
|
|
42242
|
+
return reply.code(409).send({
|
|
42243
|
+
error: "The provider cannot change once the session has turns \u2014 start a new session to use another provider"
|
|
42244
|
+
});
|
|
42245
|
+
}
|
|
42154
42246
|
}
|
|
42155
42247
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
42156
42248
|
const updates = ["updated_at = ?"];
|
|
42157
42249
|
const params = [now];
|
|
42158
|
-
let providerChanged = false;
|
|
42159
42250
|
if (title !== void 0) {
|
|
42160
42251
|
updates.push("title = ?");
|
|
42161
42252
|
params.push(title);
|
|
@@ -42172,8 +42263,7 @@ async function registerSessionRoutes(fastify) {
|
|
|
42172
42263
|
updates.push("starred = ?");
|
|
42173
42264
|
params.push(starred);
|
|
42174
42265
|
}
|
|
42175
|
-
if (
|
|
42176
|
-
providerChanged = true;
|
|
42266
|
+
if (providerChanged) {
|
|
42177
42267
|
updates.push("runtime_type = ?");
|
|
42178
42268
|
params.push(runtime_type);
|
|
42179
42269
|
if (model === void 0) {
|
|
@@ -42211,6 +42301,12 @@ async function registerSessionRoutes(fastify) {
|
|
|
42211
42301
|
if (model_reasoning_effort !== void 0) {
|
|
42212
42302
|
updates.push("model_reasoning_effort = ?");
|
|
42213
42303
|
params.push(model_reasoning_effort);
|
|
42304
|
+
if (model_reasoning_effort !== existing.model_reasoning_effort && !providerChanged) {
|
|
42305
|
+
const provider = getProvider(existing.runtime_type);
|
|
42306
|
+
provider.setEffort?.(id, model_reasoning_effort).catch((err) => {
|
|
42307
|
+
console.error(`[patch] setEffort failed for session ${id}:`, err);
|
|
42308
|
+
});
|
|
42309
|
+
}
|
|
42214
42310
|
}
|
|
42215
42311
|
if (runtime_config !== void 0) {
|
|
42216
42312
|
updates.push("runtime_config = ?");
|
|
@@ -42219,10 +42315,14 @@ async function registerSessionRoutes(fastify) {
|
|
|
42219
42315
|
db2.prepare(`UPDATE sessions SET ${updates.join(", ")} WHERE id = ?`).run(...params, id);
|
|
42220
42316
|
if (title !== void 0) markSessionTouched(db2, id);
|
|
42221
42317
|
if (providerChanged || workspaceChanged) {
|
|
42222
|
-
|
|
42223
|
-
|
|
42224
|
-
|
|
42225
|
-
|
|
42318
|
+
const provider = getProvider(existing.runtime_type);
|
|
42319
|
+
commitRewind(db2, id, provider.clearThreadBranch?.bind(provider));
|
|
42320
|
+
db2.prepare(
|
|
42321
|
+
`UPDATE sessions SET external_thread_id = NULL, rewound_at_turn_id = NULL, pre_rewind_thread_id = NULL,
|
|
42322
|
+
pre_rewind_turn_ids = NULL, context_usage = NULL, updated_at = ? WHERE id = ?`
|
|
42323
|
+
).run(now, id);
|
|
42324
|
+
db2.prepare("UPDATE turns SET external_turn_id = NULL WHERE session_id = ? AND thread_id IS NULL").run(id);
|
|
42325
|
+
provider.clearThread(id);
|
|
42226
42326
|
}
|
|
42227
42327
|
const session = db2.prepare("SELECT * FROM sessions WHERE id = ?").get(id);
|
|
42228
42328
|
broadcast("session:updated", { session });
|
|
@@ -42259,6 +42359,9 @@ async function registerSessionRoutes(fastify) {
|
|
|
42259
42359
|
if (!targetTurnFull) {
|
|
42260
42360
|
return reply.code(404).send({ error: "Turn not found" });
|
|
42261
42361
|
}
|
|
42362
|
+
if (targetTurnFull.thread_id != null) {
|
|
42363
|
+
return reply.code(400).send({ error: "Cannot rewind to a discussion thread turn" });
|
|
42364
|
+
}
|
|
42262
42365
|
const provider = getProvider(session.runtime_type);
|
|
42263
42366
|
if (provider.rewindRuntime) {
|
|
42264
42367
|
await provider.rewindRuntime(session, targetTurnFull);
|
|
@@ -42271,37 +42374,48 @@ async function registerSessionRoutes(fastify) {
|
|
|
42271
42374
|
targetTurnFull.created_at
|
|
42272
42375
|
);
|
|
42273
42376
|
db2.prepare(
|
|
42274
|
-
"UPDATE sessions SET rewound_at_turn_id = NULL, pre_rewind_thread_id = NULL, updated_at = ? WHERE id = ?"
|
|
42377
|
+
"UPDATE sessions SET rewound_at_turn_id = NULL, pre_rewind_thread_id = NULL, pre_rewind_turn_ids = NULL, updated_at = ? WHERE id = ?"
|
|
42275
42378
|
).run(now2, id);
|
|
42276
42379
|
markSessionTouched(db2, id);
|
|
42277
42380
|
const truncated = db2.prepare("SELECT * FROM sessions WHERE id = ?").get(id);
|
|
42278
42381
|
return truncated;
|
|
42279
42382
|
}
|
|
42280
|
-
|
|
42281
|
-
|
|
42282
|
-
db2.prepare(
|
|
42283
|
-
"UPDATE sessions SET rewound_at_turn_id = ?, pre_rewind_thread_id = ?, updated_at = ? WHERE id = ?"
|
|
42284
|
-
).run(turn_id, session.external_thread_id, now, id);
|
|
42285
|
-
console.log(`[rewind] saved pre_rewind_thread_id=${session.external_thread_id} for session ${id}`);
|
|
42286
|
-
} else {
|
|
42287
|
-
db2.prepare(
|
|
42288
|
-
"UPDATE sessions SET rewound_at_turn_id = ?, updated_at = ? WHERE id = ?"
|
|
42289
|
-
).run(turn_id, now, id);
|
|
42290
|
-
console.log(`[rewind] pre_rewind_thread_id already set (${session.pre_rewind_thread_id}) or external_thread_id is null for session ${id}`);
|
|
42291
|
-
}
|
|
42383
|
+
let forkedId = session.external_thread_id;
|
|
42384
|
+
let turnIds = /* @__PURE__ */ new Map();
|
|
42292
42385
|
if (provider.forkSession) {
|
|
42293
42386
|
try {
|
|
42294
|
-
|
|
42295
|
-
if (forkedId) {
|
|
42296
|
-
db2.prepare("UPDATE sessions SET external_thread_id = ?, updated_at = ? WHERE id = ?").run(forkedId, now, id);
|
|
42297
|
-
console.log(`[rewind] forked to ${forkedId} for session ${id}`);
|
|
42298
|
-
} else {
|
|
42299
|
-
console.warn(`[rewind] forkSession returned null for session ${id} (external_thread_id=${session.external_thread_id}, upToMessageId=${targetTurnFull.external_turn_id})`);
|
|
42300
|
-
}
|
|
42387
|
+
forkedId = await provider.forkSession(session, targetTurnFull);
|
|
42301
42388
|
} catch (err) {
|
|
42302
42389
|
console.error(`[rewind] forkSession threw for session ${id}:`, err);
|
|
42390
|
+
return reply.code(409).send({
|
|
42391
|
+
error: `Cannot rewind to this turn: the runtime could not fork its conversation there (${err.message})`
|
|
42392
|
+
});
|
|
42393
|
+
}
|
|
42394
|
+
if (forkedId && provider.forkedTurnIds) {
|
|
42395
|
+
turnIds = await provider.forkedTurnIds(session, forkedId).catch((err) => {
|
|
42396
|
+
console.warn(`[rewind] could not read the turn ids of fork ${forkedId}:`, err);
|
|
42397
|
+
return /* @__PURE__ */ new Map();
|
|
42398
|
+
});
|
|
42303
42399
|
}
|
|
42304
42400
|
}
|
|
42401
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
42402
|
+
db2.transaction(() => {
|
|
42403
|
+
if (!session.rewound_at_turn_id) {
|
|
42404
|
+
db2.prepare("UPDATE sessions SET pre_rewind_thread_id = ?, pre_rewind_turn_ids = ? WHERE id = ?").run(
|
|
42405
|
+
session.external_thread_id,
|
|
42406
|
+
snapshotTurnIds(db2, id),
|
|
42407
|
+
id
|
|
42408
|
+
);
|
|
42409
|
+
}
|
|
42410
|
+
db2.prepare("UPDATE sessions SET rewound_at_turn_id = ?, external_thread_id = ?, updated_at = ? WHERE id = ?").run(
|
|
42411
|
+
turn_id,
|
|
42412
|
+
forkedId,
|
|
42413
|
+
now,
|
|
42414
|
+
id
|
|
42415
|
+
);
|
|
42416
|
+
applyTurnIdMap(db2, id, turnIds, targetTurnFull.created_at);
|
|
42417
|
+
})();
|
|
42418
|
+
console.log(`[rewind] session ${id} rewound to ${turn_id}, runtime thread ${forkedId ?? "(none)"}`);
|
|
42305
42419
|
provider.clearThread(id);
|
|
42306
42420
|
markSessionTouched(db2, id);
|
|
42307
42421
|
const updated = db2.prepare("SELECT * FROM sessions WHERE id = ?").get(id);
|
|
@@ -42323,10 +42437,17 @@ async function registerSessionRoutes(fastify) {
|
|
|
42323
42437
|
error: "Restore is not available for repoburg sessions \u2014 the rewind permanently deleted the runtime history."
|
|
42324
42438
|
});
|
|
42325
42439
|
}
|
|
42440
|
+
if (session.is_running) {
|
|
42441
|
+
return reply.code(409).send({ error: "Cannot restore while a turn is running" });
|
|
42442
|
+
}
|
|
42326
42443
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
42327
|
-
db2.
|
|
42328
|
-
|
|
42329
|
-
|
|
42444
|
+
db2.transaction(() => {
|
|
42445
|
+
restoreTurnIds(db2, id, session.pre_rewind_turn_ids);
|
|
42446
|
+
db2.prepare(
|
|
42447
|
+
`UPDATE sessions SET rewound_at_turn_id = NULL, pre_rewind_thread_id = NULL, pre_rewind_turn_ids = NULL,
|
|
42448
|
+
external_thread_id = COALESCE(pre_rewind_thread_id, external_thread_id), updated_at = ? WHERE id = ?`
|
|
42449
|
+
).run(now, id);
|
|
42450
|
+
})();
|
|
42330
42451
|
getProvider(session.runtime_type).clearThread(id);
|
|
42331
42452
|
markSessionTouched(db2, id);
|
|
42332
42453
|
const updated = db2.prepare("SELECT * FROM sessions WHERE id = ?").get(id);
|
|
@@ -42364,78 +42485,88 @@ async function registerSessionRoutes(fastify) {
|
|
|
42364
42485
|
if (targetTurn.thread_id != null) {
|
|
42365
42486
|
return reply.code(400).send({ error: "Cannot branch from a discussion thread turn" });
|
|
42366
42487
|
}
|
|
42488
|
+
const provider = getProvider(session.runtime_type);
|
|
42489
|
+
let forkedId = null;
|
|
42490
|
+
let turnIds = /* @__PURE__ */ new Map();
|
|
42491
|
+
if (provider.forkSession) {
|
|
42492
|
+
const targetTurnFull = db2.prepare("SELECT * FROM turns WHERE id = ?").get(turn_id);
|
|
42493
|
+
try {
|
|
42494
|
+
forkedId = await provider.forkSession(session, targetTurnFull);
|
|
42495
|
+
} catch (err) {
|
|
42496
|
+
console.error(`[branch] forkSession threw for session ${id}:`, err);
|
|
42497
|
+
return reply.code(409).send({
|
|
42498
|
+
error: `Cannot branch from this turn: the runtime could not fork its conversation there (${err.message})`
|
|
42499
|
+
});
|
|
42500
|
+
}
|
|
42501
|
+
if (forkedId && provider.forkedTurnIds) {
|
|
42502
|
+
turnIds = await provider.forkedTurnIds(session, forkedId).catch((err) => {
|
|
42503
|
+
console.warn(`[branch] could not read the turn ids of fork ${forkedId}:`, err);
|
|
42504
|
+
return /* @__PURE__ */ new Map();
|
|
42505
|
+
});
|
|
42506
|
+
}
|
|
42507
|
+
}
|
|
42367
42508
|
const newSessionId = v4_default();
|
|
42368
42509
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
42369
42510
|
const newTitle = title || `Branch of ${session.title || session.id.slice(0, 8)}`;
|
|
42370
|
-
db2.
|
|
42371
|
-
`INSERT INTO sessions (id, title, runtime_type, model, model_reasoning_effort, cwd, external_thread_id, status, is_running, lifecycle, has_unreviewed, created_at, updated_at, runtime_config)
|
|
42372
|
-
VALUES (?, ?, ?, ?, ?, ?, NULL, 'active', 0, 'working', 0, ?, ?, ?)`
|
|
42373
|
-
).run(
|
|
42374
|
-
newSessionId,
|
|
42375
|
-
newTitle,
|
|
42376
|
-
session.runtime_type,
|
|
42377
|
-
session.model,
|
|
42378
|
-
session.model_reasoning_effort,
|
|
42379
|
-
session.cwd,
|
|
42380
|
-
now,
|
|
42381
|
-
now,
|
|
42382
|
-
session.runtime_config
|
|
42383
|
-
);
|
|
42384
|
-
const turnRows = db2.prepare(
|
|
42385
|
-
"SELECT * FROM turns WHERE session_id = ? AND thread_id IS NULL AND created_at <= ? ORDER BY created_at ASC"
|
|
42386
|
-
).all(id, targetTurn.created_at);
|
|
42387
|
-
for (const turn of turnRows) {
|
|
42388
|
-
const newTurnId = v4_default();
|
|
42511
|
+
db2.transaction(() => {
|
|
42389
42512
|
db2.prepare(
|
|
42390
|
-
`INSERT INTO
|
|
42391
|
-
VALUES (?, ?, ?, ?, ?, ?, ?,
|
|
42513
|
+
`INSERT INTO sessions (id, title, runtime_type, model, model_reasoning_effort, cwd, external_thread_id, status, is_running, lifecycle, has_unreviewed, created_at, updated_at, runtime_config)
|
|
42514
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, 'active', 0, 'working', 0, ?, ?, ?)`
|
|
42392
42515
|
).run(
|
|
42393
|
-
newTurnId,
|
|
42394
42516
|
newSessionId,
|
|
42395
|
-
|
|
42396
|
-
|
|
42397
|
-
|
|
42398
|
-
|
|
42399
|
-
|
|
42400
|
-
|
|
42401
|
-
|
|
42402
|
-
|
|
42403
|
-
|
|
42404
|
-
turn.origin_name ?? null,
|
|
42405
|
-
turn.created_at,
|
|
42406
|
-
turn.updated_at
|
|
42517
|
+
newTitle,
|
|
42518
|
+
session.runtime_type,
|
|
42519
|
+
session.model,
|
|
42520
|
+
session.model_reasoning_effort,
|
|
42521
|
+
session.cwd,
|
|
42522
|
+
forkedId,
|
|
42523
|
+
now,
|
|
42524
|
+
now,
|
|
42525
|
+
session.runtime_config
|
|
42407
42526
|
);
|
|
42408
|
-
const
|
|
42409
|
-
|
|
42410
|
-
|
|
42527
|
+
const turnRows = db2.prepare(
|
|
42528
|
+
"SELECT * FROM turns WHERE session_id = ? AND thread_id IS NULL AND created_at <= ? ORDER BY created_at ASC"
|
|
42529
|
+
).all(id, targetTurn.created_at);
|
|
42530
|
+
for (const turn of turnRows) {
|
|
42531
|
+
const newTurnId = v4_default();
|
|
42411
42532
|
db2.prepare(
|
|
42412
|
-
`INSERT INTO
|
|
42413
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`
|
|
42533
|
+
`INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, attachments, origin, origin_name, created_at, updated_at)
|
|
42534
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
|
42414
42535
|
).run(
|
|
42415
|
-
newItemId,
|
|
42416
42536
|
newTurnId,
|
|
42417
|
-
|
|
42418
|
-
|
|
42419
|
-
|
|
42420
|
-
|
|
42421
|
-
|
|
42422
|
-
|
|
42537
|
+
newSessionId,
|
|
42538
|
+
turn.user_prompt,
|
|
42539
|
+
turn.agent_response,
|
|
42540
|
+
turn.thoughts,
|
|
42541
|
+
turn.token_usage,
|
|
42542
|
+
(turn.external_turn_id && turnIds.get(turn.external_turn_id)) ?? turn.external_turn_id,
|
|
42543
|
+
turn.status,
|
|
42544
|
+
turn.error,
|
|
42545
|
+
turn.attachments,
|
|
42546
|
+
turn.origin ?? null,
|
|
42547
|
+
turn.origin_name ?? null,
|
|
42548
|
+
turn.created_at,
|
|
42549
|
+
turn.updated_at
|
|
42423
42550
|
);
|
|
42424
|
-
|
|
42425
|
-
|
|
42426
|
-
|
|
42427
|
-
|
|
42428
|
-
|
|
42429
|
-
|
|
42430
|
-
|
|
42431
|
-
|
|
42432
|
-
|
|
42551
|
+
const itemRows = db2.prepare("SELECT * FROM items WHERE turn_id = ? ORDER BY created_at ASC").all(turn.id);
|
|
42552
|
+
for (const item of itemRows) {
|
|
42553
|
+
const newItemId = v4_default();
|
|
42554
|
+
db2.prepare(
|
|
42555
|
+
`INSERT INTO items (id, turn_id, external_item_id, type, data, status, created_at, updated_at)
|
|
42556
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`
|
|
42557
|
+
).run(
|
|
42558
|
+
newItemId,
|
|
42559
|
+
newTurnId,
|
|
42560
|
+
item.external_item_id,
|
|
42561
|
+
item.type,
|
|
42562
|
+
item.data,
|
|
42563
|
+
item.status,
|
|
42564
|
+
item.created_at,
|
|
42565
|
+
item.updated_at
|
|
42566
|
+
);
|
|
42433
42567
|
}
|
|
42434
|
-
} catch (forkError) {
|
|
42435
|
-
db2.prepare("DELETE FROM sessions WHERE id = ?").run(newSessionId);
|
|
42436
|
-
throw forkError;
|
|
42437
42568
|
}
|
|
42438
|
-
}
|
|
42569
|
+
})();
|
|
42439
42570
|
const newSession = db2.prepare("SELECT * FROM sessions WHERE id = ?").get(newSessionId);
|
|
42440
42571
|
return newSession;
|
|
42441
42572
|
}
|
|
@@ -43802,7 +43933,26 @@ async function registerProviderRoutes(fastify) {
|
|
|
43802
43933
|
);
|
|
43803
43934
|
}
|
|
43804
43935
|
|
|
43936
|
+
// src/providers/runtime-provider.ts
|
|
43937
|
+
var InferenceCredentialsError = class extends Error {
|
|
43938
|
+
};
|
|
43939
|
+
|
|
43805
43940
|
// src/routes/models.ts
|
|
43941
|
+
function inferenceRuntime(id, reply) {
|
|
43942
|
+
const provider = hasProvider(id) ? getProvider(id) : void 0;
|
|
43943
|
+
if (!provider?.getInferenceProviders) {
|
|
43944
|
+
void reply.code(404).send({ error: `Provider ${id} has no inference providers` });
|
|
43945
|
+
return void 0;
|
|
43946
|
+
}
|
|
43947
|
+
return provider;
|
|
43948
|
+
}
|
|
43949
|
+
function sendInferenceError(reply, error51) {
|
|
43950
|
+
if (error51 instanceof InferenceCredentialsError) {
|
|
43951
|
+
return reply.code(400).send({ error: error51.message });
|
|
43952
|
+
}
|
|
43953
|
+
const message = error51 instanceof Error ? error51.message : String(error51);
|
|
43954
|
+
return reply.code(503).send({ error: message });
|
|
43955
|
+
}
|
|
43806
43956
|
async function registerModelRoutes(fastify) {
|
|
43807
43957
|
fastify.get(
|
|
43808
43958
|
"/api/providers/:id/models",
|
|
@@ -43814,6 +43964,54 @@ async function registerModelRoutes(fastify) {
|
|
|
43814
43964
|
return getProvider(id).getModels(request.query.cwd);
|
|
43815
43965
|
}
|
|
43816
43966
|
);
|
|
43967
|
+
fastify.get(
|
|
43968
|
+
"/api/providers/:id/inference",
|
|
43969
|
+
async (request, reply) => {
|
|
43970
|
+
const provider = inferenceRuntime(request.params.id, reply);
|
|
43971
|
+
if (!provider) return reply;
|
|
43972
|
+
try {
|
|
43973
|
+
return await provider.getInferenceProviders(request.query.cwd);
|
|
43974
|
+
} catch (error51) {
|
|
43975
|
+
return sendInferenceError(reply, error51);
|
|
43976
|
+
}
|
|
43977
|
+
}
|
|
43978
|
+
);
|
|
43979
|
+
fastify.put(
|
|
43980
|
+
"/api/providers/:id/inference/:inferenceId/credentials",
|
|
43981
|
+
async (request, reply) => {
|
|
43982
|
+
const provider = inferenceRuntime(request.params.id, reply);
|
|
43983
|
+
if (!provider) return reply;
|
|
43984
|
+
if (!provider.setInferenceCredentials) {
|
|
43985
|
+
return reply.code(404).send({ error: "This provider cannot save keys" });
|
|
43986
|
+
}
|
|
43987
|
+
const body = request.body ?? {};
|
|
43988
|
+
const field = (value) => typeof value === "string" ? value : void 0;
|
|
43989
|
+
try {
|
|
43990
|
+
return await provider.setInferenceCredentials(request.params.inferenceId, {
|
|
43991
|
+
apiKey: field(body.apiKey),
|
|
43992
|
+
baseUrl: field(body.baseUrl),
|
|
43993
|
+
cwd: field(body.cwd)
|
|
43994
|
+
});
|
|
43995
|
+
} catch (error51) {
|
|
43996
|
+
return sendInferenceError(reply, error51);
|
|
43997
|
+
}
|
|
43998
|
+
}
|
|
43999
|
+
);
|
|
44000
|
+
fastify.delete(
|
|
44001
|
+
"/api/providers/:id/inference/:inferenceId/credentials",
|
|
44002
|
+
async (request, reply) => {
|
|
44003
|
+
const provider = inferenceRuntime(request.params.id, reply);
|
|
44004
|
+
if (!provider) return reply;
|
|
44005
|
+
if (!provider.removeInferenceCredentials) {
|
|
44006
|
+
return reply.code(404).send({ error: "This provider cannot remove keys" });
|
|
44007
|
+
}
|
|
44008
|
+
try {
|
|
44009
|
+
return await provider.removeInferenceCredentials(request.params.inferenceId, request.query.cwd);
|
|
44010
|
+
} catch (error51) {
|
|
44011
|
+
return sendInferenceError(reply, error51);
|
|
44012
|
+
}
|
|
44013
|
+
}
|
|
44014
|
+
);
|
|
43817
44015
|
}
|
|
43818
44016
|
|
|
43819
44017
|
// src/routes/skills.ts
|
|
@@ -119699,7 +119897,7 @@ function threadParams(session, cwd, browserInstructions) {
|
|
|
119699
119897
|
cwd,
|
|
119700
119898
|
approvalPolicy: "never",
|
|
119701
119899
|
sandbox: sandboxType(config3),
|
|
119702
|
-
model: session.model
|
|
119900
|
+
model: session.model || void 0,
|
|
119703
119901
|
config: threadConfig(config3),
|
|
119704
119902
|
...threadInstructionParams(cwd, browserInstructions)
|
|
119705
119903
|
};
|
|
@@ -120238,8 +120436,8 @@ async function sendTurnRequest(session, entry, threadId, request) {
|
|
|
120238
120436
|
input: request.input,
|
|
120239
120437
|
approvalPolicy: "never",
|
|
120240
120438
|
...policy ? { sandboxPolicy: policy } : {},
|
|
120241
|
-
model: session.model
|
|
120242
|
-
effort: session.model_reasoning_effort
|
|
120439
|
+
model: session.model || void 0,
|
|
120440
|
+
effort: session.model_reasoning_effort || void 0
|
|
120243
120441
|
});
|
|
120244
120442
|
return result.turn.id;
|
|
120245
120443
|
}
|
|
@@ -120708,15 +120906,6 @@ async function getModels() {
|
|
|
120708
120906
|
async function getCommands() {
|
|
120709
120907
|
return CODEX_COMMANDS;
|
|
120710
120908
|
}
|
|
120711
|
-
function forkPoint(db2, sessionId, target) {
|
|
120712
|
-
const row = db2.prepare(
|
|
120713
|
-
`SELECT external_turn_id FROM turns
|
|
120714
|
-
WHERE session_id = ? AND thread_id IS NULL AND external_turn_id IS NOT NULL
|
|
120715
|
-
AND status NOT IN ('pending', 'running') AND (id = ? OR created_at < ?)
|
|
120716
|
-
ORDER BY created_at DESC, rowid DESC LIMIT 1`
|
|
120717
|
-
).get(sessionId, target.id, target.created_at);
|
|
120718
|
-
return row?.external_turn_id ?? null;
|
|
120719
|
-
}
|
|
120720
120909
|
async function forkSession(session, targetTurn) {
|
|
120721
120910
|
const threadId = session.external_thread_id;
|
|
120722
120911
|
if (!threadId) return null;
|
|
@@ -121235,7 +121424,7 @@ var codexProvider = {
|
|
|
121235
121424
|
};
|
|
121236
121425
|
|
|
121237
121426
|
// src/claude/claude-provider.ts
|
|
121238
|
-
import { query, forkSession as sdkForkSession } from "@anthropic-ai/claude-agent-sdk";
|
|
121427
|
+
import { query, forkSession as sdkForkSession, importSessionToStore } from "@anthropic-ai/claude-agent-sdk";
|
|
121239
121428
|
import { readFileSync as readFileSync4 } from "fs";
|
|
121240
121429
|
import { tmpdir } from "os";
|
|
121241
121430
|
import { join as join5 } from "path";
|
|
@@ -121996,7 +122185,7 @@ async function ensureSessionStarted(session, mapKey, resumeSessionId, resume, ad
|
|
|
121996
122185
|
}
|
|
121997
122186
|
const options = {
|
|
121998
122187
|
cwd,
|
|
121999
|
-
model: session.model
|
|
122188
|
+
model: session.model || void 0,
|
|
122000
122189
|
permissionMode: "bypassPermissions",
|
|
122001
122190
|
allowDangerouslySkipPermissions: true,
|
|
122002
122191
|
includePartialMessages: true,
|
|
@@ -122206,6 +122395,7 @@ function openPeerTurn(entry, sessionId, peer, db2) {
|
|
|
122206
122395
|
}
|
|
122207
122396
|
if (previous) streamingMessageIds.delete(previous);
|
|
122208
122397
|
const threadId = entry.threadId ?? null;
|
|
122398
|
+
if (!threadId) commitRewind(db2, sessionId, clearThreadBranch2);
|
|
122209
122399
|
const turnId = v4_default();
|
|
122210
122400
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
122211
122401
|
const inputIds = peer.uuid ? JSON.stringify([peer.uuid]) : null;
|
|
@@ -123042,9 +123232,14 @@ function sweepFinishedSessions(now = Date.now()) {
|
|
|
123042
123232
|
async function setModel(sessionId, model) {
|
|
123043
123233
|
const entry = sessionMap2.get(sessionId);
|
|
123044
123234
|
if (!entry) return;
|
|
123045
|
-
await entry.query.setModel(model);
|
|
123235
|
+
await entry.query.setModel(model || void 0);
|
|
123046
123236
|
void refreshContext(entry, sessionId, getDb());
|
|
123047
123237
|
}
|
|
123238
|
+
async function setEffort(sessionId, effort) {
|
|
123239
|
+
const entry = sessionMap2.get(sessionId);
|
|
123240
|
+
if (!entry) return;
|
|
123241
|
+
await entry.query.applyFlagSettings({ effortLevel: effort || null });
|
|
123242
|
+
}
|
|
123048
123243
|
async function stopTask2(sessionId, taskId) {
|
|
123049
123244
|
const entry = sessionMap2.get(sessionId);
|
|
123050
123245
|
if (!entry) return;
|
|
@@ -123068,7 +123263,9 @@ function loadCatalog() {
|
|
|
123068
123263
|
slug: m.value,
|
|
123069
123264
|
displayName: m.displayName,
|
|
123070
123265
|
description: m.description,
|
|
123071
|
-
|
|
123266
|
+
// The SDK names no default effort (its levels list starts at 'low'):
|
|
123267
|
+
// '' = the CLI's own default for the model.
|
|
123268
|
+
defaultReasoning: "",
|
|
123072
123269
|
reasoningLevels: (m.supportedEffortLevels ?? []).map((e) => ({
|
|
123073
123270
|
effort: e,
|
|
123074
123271
|
label: EFFORT_LABELS2[e] ?? e
|
|
@@ -123279,16 +123476,32 @@ async function summarizeClaudeThread(session, thread, transcript, directives) {
|
|
|
123279
123476
|
}
|
|
123280
123477
|
async function forkClaudeSession(session, targetTurn) {
|
|
123281
123478
|
if (!session.external_thread_id) return null;
|
|
123282
|
-
|
|
123283
|
-
|
|
123284
|
-
|
|
123285
|
-
|
|
123286
|
-
|
|
123287
|
-
|
|
123288
|
-
|
|
123289
|
-
|
|
123290
|
-
|
|
123479
|
+
const upToMessageId = forkPoint(getDb(), session.id, targetTurn);
|
|
123480
|
+
if (!upToMessageId) return null;
|
|
123481
|
+
const result = await sdkForkSession(session.external_thread_id, {
|
|
123482
|
+
dir: session.cwd ?? process.cwd(),
|
|
123483
|
+
upToMessageId
|
|
123484
|
+
});
|
|
123485
|
+
return result.sessionId;
|
|
123486
|
+
}
|
|
123487
|
+
async function forkedTurnIds(session, forkedId) {
|
|
123488
|
+
const entries = [];
|
|
123489
|
+
await importSessionToStore(
|
|
123490
|
+
forkedId,
|
|
123491
|
+
{
|
|
123492
|
+
append: async (_key, batch) => {
|
|
123493
|
+
entries.push(...batch);
|
|
123494
|
+
},
|
|
123495
|
+
load: async () => null
|
|
123496
|
+
},
|
|
123497
|
+
{ dir: session.cwd ?? process.cwd(), includeSubagents: false }
|
|
123498
|
+
);
|
|
123499
|
+
const ids = /* @__PURE__ */ new Map();
|
|
123500
|
+
for (const entry of entries) {
|
|
123501
|
+
const source = entry.forkedFrom?.messageUuid;
|
|
123502
|
+
if (typeof source === "string" && entry.uuid) ids.set(source, entry.uuid);
|
|
123291
123503
|
}
|
|
123504
|
+
return ids;
|
|
123292
123505
|
}
|
|
123293
123506
|
var REPLAY_WAIT_MS2 = 3e4;
|
|
123294
123507
|
function startReplay(entry) {
|
|
@@ -123407,8 +123620,15 @@ function describeExit2(exit) {
|
|
|
123407
123620
|
function deadEntry(session, row) {
|
|
123408
123621
|
const gone = () => Promise.reject(new Error("the CLI is gone"));
|
|
123409
123622
|
const entry = {
|
|
123410
|
-
query: {
|
|
123411
|
-
|
|
123623
|
+
query: {
|
|
123624
|
+
getContextUsage: gone,
|
|
123625
|
+
interrupt: gone,
|
|
123626
|
+
setModel: gone,
|
|
123627
|
+
applyFlagSettings: gone,
|
|
123628
|
+
stopTask: gone,
|
|
123629
|
+
close: () => {
|
|
123630
|
+
}
|
|
123631
|
+
},
|
|
123412
123632
|
sessionId: row.external_id,
|
|
123413
123633
|
turnId: row.turn_id,
|
|
123414
123634
|
cwd: session.cwd ?? process.cwd(),
|
|
@@ -123507,8 +123727,10 @@ var claudeProvider = {
|
|
|
123507
123727
|
getModels: getModels2,
|
|
123508
123728
|
getCommands: getCommands2,
|
|
123509
123729
|
forkSession: forkClaudeSession,
|
|
123730
|
+
forkedTurnIds,
|
|
123510
123731
|
summarizeThread: summarizeClaudeThread,
|
|
123511
123732
|
setModel,
|
|
123733
|
+
setEffort,
|
|
123512
123734
|
stopTask: stopTask2,
|
|
123513
123735
|
listBackgroundTasks: listBackgroundTasks2,
|
|
123514
123736
|
resumeInterruptedTurn: resumeInterruptedTurn2,
|
|
@@ -123517,6 +123739,22 @@ var claudeProvider = {
|
|
|
123517
123739
|
};
|
|
123518
123740
|
|
|
123519
123741
|
// src/repoburg/repoburg-client.ts
|
|
123742
|
+
var RepoburgHttpError = class extends Error {
|
|
123743
|
+
constructor(message, status, detail) {
|
|
123744
|
+
super(message);
|
|
123745
|
+
this.status = status;
|
|
123746
|
+
this.detail = detail;
|
|
123747
|
+
}
|
|
123748
|
+
};
|
|
123749
|
+
function errorDetail(body) {
|
|
123750
|
+
const parsed = body;
|
|
123751
|
+
const message = parsed?.error && typeof parsed.error === "object" ? parsed.error.message : parsed?.message;
|
|
123752
|
+
if (typeof message === "string") return message || null;
|
|
123753
|
+
if (Array.isArray(message)) {
|
|
123754
|
+
return message.filter((m) => typeof m === "string").join("; ") || null;
|
|
123755
|
+
}
|
|
123756
|
+
return null;
|
|
123757
|
+
}
|
|
123520
123758
|
function defaultRepoburgBaseUrl() {
|
|
123521
123759
|
return process.env.REPOBURG_BACKEND_URL || "http://localhost:3000";
|
|
123522
123760
|
}
|
|
@@ -123544,7 +123782,12 @@ var RepoburgHttpClient = class {
|
|
|
123544
123782
|
`${method} ${path21} failed: ${response.status} HTML response from ${this.baseUrl} \u2014 the URL points to the wrong server`
|
|
123545
123783
|
);
|
|
123546
123784
|
}
|
|
123547
|
-
|
|
123785
|
+
let detail = null;
|
|
123786
|
+
try {
|
|
123787
|
+
detail = errorDetail(JSON.parse(text2));
|
|
123788
|
+
} catch {
|
|
123789
|
+
}
|
|
123790
|
+
throw new RepoburgHttpError(`${method} ${path21} failed: ${response.status} ${text2}`, response.status, detail);
|
|
123548
123791
|
}
|
|
123549
123792
|
if (text2.length === 0) return void 0;
|
|
123550
123793
|
try {
|
|
@@ -123600,6 +123843,26 @@ var RepoburgHttpClient = class {
|
|
|
123600
123843
|
const result = await this.request("GET", "/llm-provider/models");
|
|
123601
123844
|
return result.models ?? [];
|
|
123602
123845
|
}
|
|
123846
|
+
async getInferenceProviders() {
|
|
123847
|
+
const result = await this.request(
|
|
123848
|
+
"GET",
|
|
123849
|
+
"/llm-provider/inference-providers"
|
|
123850
|
+
);
|
|
123851
|
+
return result.providers ?? [];
|
|
123852
|
+
}
|
|
123853
|
+
async setInferenceCredentials(id, dto) {
|
|
123854
|
+
return this.request(
|
|
123855
|
+
"PUT",
|
|
123856
|
+
`/llm-provider/inference-providers/${encodeURIComponent(id)}/credentials`,
|
|
123857
|
+
dto
|
|
123858
|
+
);
|
|
123859
|
+
}
|
|
123860
|
+
async removeInferenceCredentials(id) {
|
|
123861
|
+
return this.request(
|
|
123862
|
+
"DELETE",
|
|
123863
|
+
`/llm-provider/inference-providers/${encodeURIComponent(id)}/credentials`
|
|
123864
|
+
);
|
|
123865
|
+
}
|
|
123603
123866
|
async getSlashCommands() {
|
|
123604
123867
|
return this.request("GET", "/slash-commands");
|
|
123605
123868
|
}
|
|
@@ -124774,22 +125037,27 @@ function cleanTitle(raw) {
|
|
|
124774
125037
|
}
|
|
124775
125038
|
|
|
124776
125039
|
// src/repoburg/repoburg-provider.ts
|
|
124777
|
-
var
|
|
125040
|
+
var FALLBACK_REASONING_LEVELS = [
|
|
124778
125041
|
{ effort: "low", label: "Low" },
|
|
124779
125042
|
{ effort: "medium", label: "Medium" },
|
|
124780
125043
|
{ effort: "high", label: "High" },
|
|
124781
125044
|
{ effort: "xhigh", label: "Extra High" }
|
|
124782
125045
|
];
|
|
124783
|
-
var
|
|
124784
|
-
|
|
124785
|
-
|
|
124786
|
-
|
|
124787
|
-
|
|
124788
|
-
|
|
124789
|
-
|
|
124790
|
-
|
|
124791
|
-
|
|
124792
|
-
|
|
125046
|
+
var FALLBACK_OLLAMA_LEVELS = FALLBACK_REASONING_LEVELS.filter((l) => l.effort !== "xhigh");
|
|
125047
|
+
var RUNTIME_EFFORTS = /* @__PURE__ */ new Set(["none", "minimal", "low", "medium", "high", "xhigh", "max"]);
|
|
125048
|
+
function mapReasoningEffort(effort) {
|
|
125049
|
+
return effort && RUNTIME_EFFORTS.has(effort) ? effort : void 0;
|
|
125050
|
+
}
|
|
125051
|
+
var INFERENCE_PROVIDER_IDS = /* @__PURE__ */ new Set(["ollama", "zai", "alibaba", "openrouter", "openai"]);
|
|
125052
|
+
function inferenceProviderOf(modelId) {
|
|
125053
|
+
const slash = modelId.indexOf("/");
|
|
125054
|
+
if (slash <= 0) return void 0;
|
|
125055
|
+
const prefix = modelId.slice(0, slash);
|
|
125056
|
+
return INFERENCE_PROVIDER_IDS.has(prefix) ? prefix : "openrouter";
|
|
125057
|
+
}
|
|
125058
|
+
function httpStatus(error51) {
|
|
125059
|
+
const status = error51?.status;
|
|
125060
|
+
return typeof status === "number" ? status : void 0;
|
|
124793
125061
|
}
|
|
124794
125062
|
var sessionMap3 = /* @__PURE__ */ new Map();
|
|
124795
125063
|
var STALLED_STREAM_MS = 6e4;
|
|
@@ -124811,7 +125079,7 @@ async function ensureSession(session, client, baseUrl) {
|
|
|
124811
125079
|
repoburgSessionId: session.external_thread_id,
|
|
124812
125080
|
client,
|
|
124813
125081
|
baseUrl,
|
|
124814
|
-
modelId: session.model
|
|
125082
|
+
modelId: session.model || null,
|
|
124815
125083
|
// undefined forces a re-push on the next turn — heals sessions created
|
|
124816
125084
|
// before unsafe effort values (e.g. ollama xhigh) were clamped.
|
|
124817
125085
|
reasoningEffort: void 0,
|
|
@@ -124823,10 +125091,10 @@ async function ensureSession(session, client, baseUrl) {
|
|
|
124823
125091
|
sessionMap3.set(session.id, entry2);
|
|
124824
125092
|
return entry2;
|
|
124825
125093
|
}
|
|
124826
|
-
const mappedEffort = mapReasoningEffort(session.
|
|
125094
|
+
const mappedEffort = mapReasoningEffort(session.model_reasoning_effort);
|
|
124827
125095
|
const created = await client.createSession({
|
|
124828
125096
|
session_title: session.title ?? void 0,
|
|
124829
|
-
model_id: session.model
|
|
125097
|
+
model_id: session.model || void 0,
|
|
124830
125098
|
reasoning_effort: mappedEffort
|
|
124831
125099
|
});
|
|
124832
125100
|
const db2 = getDb();
|
|
@@ -124841,7 +125109,7 @@ async function ensureSession(session, client, baseUrl) {
|
|
|
124841
125109
|
repoburgSessionId: created.id,
|
|
124842
125110
|
client,
|
|
124843
125111
|
baseUrl,
|
|
124844
|
-
modelId: session.model
|
|
125112
|
+
modelId: session.model || null,
|
|
124845
125113
|
reasoningEffort: mappedEffort,
|
|
124846
125114
|
threadId: null,
|
|
124847
125115
|
contextWindow: null,
|
|
@@ -124861,8 +125129,8 @@ async function ensureThreadSession(session, turn, client, baseUrl) {
|
|
|
124861
125129
|
if (!runtimeId) {
|
|
124862
125130
|
const created = await client.createSession({
|
|
124863
125131
|
session_title: session.title ? `Discussion: ${session.title}` : "Discussion",
|
|
124864
|
-
model_id: session.model
|
|
124865
|
-
reasoning_effort: mapReasoningEffort(session.
|
|
125132
|
+
model_id: session.model || void 0,
|
|
125133
|
+
reasoning_effort: mapReasoningEffort(session.model_reasoning_effort)
|
|
124866
125134
|
});
|
|
124867
125135
|
runtimeId = created.id;
|
|
124868
125136
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -124877,7 +125145,7 @@ async function ensureThreadSession(session, turn, client, baseUrl) {
|
|
|
124877
125145
|
repoburgSessionId: runtimeId,
|
|
124878
125146
|
client,
|
|
124879
125147
|
baseUrl,
|
|
124880
|
-
modelId: session.model
|
|
125148
|
+
modelId: session.model || null,
|
|
124881
125149
|
reasoningEffort: void 0,
|
|
124882
125150
|
// re-pushed on the first thread turn
|
|
124883
125151
|
threadId: turn.thread_id,
|
|
@@ -125067,8 +125335,8 @@ async function startTurn4(session, turn) {
|
|
|
125067
125335
|
entry.baseUrl = baseUrl;
|
|
125068
125336
|
entry.client = client;
|
|
125069
125337
|
}
|
|
125070
|
-
const wantedModel = session.model
|
|
125071
|
-
const wantedEffort = mapReasoningEffort(session.
|
|
125338
|
+
const wantedModel = session.model || null;
|
|
125339
|
+
const wantedEffort = mapReasoningEffort(session.model_reasoning_effort);
|
|
125072
125340
|
if (wantedModel !== entry.modelId || wantedEffort !== entry.reasoningEffort) {
|
|
125073
125341
|
try {
|
|
125074
125342
|
await entry.client.patchSession(entry.repoburgSessionId, {
|
|
@@ -125348,18 +125616,72 @@ async function getModels3(cwd) {
|
|
|
125348
125616
|
const resolved = await resolveBackendUrl(cwd ?? process.cwd(), { autoStart: false });
|
|
125349
125617
|
if (!resolved) return [];
|
|
125350
125618
|
const models = await new RepoburgHttpClient(resolved.baseUrl).getModels();
|
|
125351
|
-
return models.map((m) =>
|
|
125352
|
-
|
|
125353
|
-
|
|
125354
|
-
|
|
125355
|
-
|
|
125356
|
-
|
|
125357
|
-
|
|
125358
|
-
|
|
125619
|
+
return models.map((m) => {
|
|
125620
|
+
const levels = m.reasoning_levels ?? (m.id.startsWith("ollama/") ? FALLBACK_OLLAMA_LEVELS : FALLBACK_REASONING_LEVELS);
|
|
125621
|
+
const inferenceProvider = m.provider ?? inferenceProviderOf(m.id);
|
|
125622
|
+
return {
|
|
125623
|
+
slug: m.id,
|
|
125624
|
+
displayName: m.name,
|
|
125625
|
+
description: m.description ?? "Repoburg backend",
|
|
125626
|
+
// '' = the model's own default, which the runtime does not name.
|
|
125627
|
+
defaultReasoning: m.default_reasoning ?? (m.reasoning_levels ? "" : "medium"),
|
|
125628
|
+
reasoningLevels: levels,
|
|
125629
|
+
...inferenceProvider ? { inferenceProvider } : {},
|
|
125630
|
+
...m.aliases?.length ? { aliases: m.aliases } : {},
|
|
125631
|
+
...m.capabilities ? { capabilities: m.capabilities } : {},
|
|
125632
|
+
...m.context_window ? { contextWindow: m.context_window } : {}
|
|
125633
|
+
};
|
|
125634
|
+
});
|
|
125359
125635
|
} catch {
|
|
125360
125636
|
return [];
|
|
125361
125637
|
}
|
|
125362
125638
|
}
|
|
125639
|
+
async function runtimeFor(cwd) {
|
|
125640
|
+
const resolved = await resolveBackendUrl(cwd ?? process.cwd(), { autoStart: Boolean(cwd) });
|
|
125641
|
+
if (!resolved) {
|
|
125642
|
+
throw new Error("Repoburg is not running for this workspace.");
|
|
125643
|
+
}
|
|
125644
|
+
return new RepoburgHttpClient(resolved.baseUrl);
|
|
125645
|
+
}
|
|
125646
|
+
async function getInferenceProviders(cwd) {
|
|
125647
|
+
const client = await runtimeFor(cwd);
|
|
125648
|
+
try {
|
|
125649
|
+
return await client.getInferenceProviders();
|
|
125650
|
+
} catch (error51) {
|
|
125651
|
+
if (httpStatus(error51) === 404) return [];
|
|
125652
|
+
throw error51;
|
|
125653
|
+
}
|
|
125654
|
+
}
|
|
125655
|
+
async function setInferenceCredentials(id, input) {
|
|
125656
|
+
const client = await runtimeFor(input.cwd);
|
|
125657
|
+
try {
|
|
125658
|
+
return await client.setInferenceCredentials(id, {
|
|
125659
|
+
...input.apiKey ? { apiKey: input.apiKey } : {},
|
|
125660
|
+
...input.baseUrl ? { baseUrl: input.baseUrl } : {}
|
|
125661
|
+
});
|
|
125662
|
+
} catch (error51) {
|
|
125663
|
+
throw credentialsError(error51);
|
|
125664
|
+
}
|
|
125665
|
+
}
|
|
125666
|
+
async function removeInferenceCredentials(id, cwd) {
|
|
125667
|
+
const client = await runtimeFor(cwd);
|
|
125668
|
+
try {
|
|
125669
|
+
return await client.removeInferenceCredentials(id);
|
|
125670
|
+
} catch (error51) {
|
|
125671
|
+
throw credentialsError(error51);
|
|
125672
|
+
}
|
|
125673
|
+
}
|
|
125674
|
+
function credentialsError(error51) {
|
|
125675
|
+
const status = httpStatus(error51);
|
|
125676
|
+
if (status === 400) {
|
|
125677
|
+
const detail = error51.detail;
|
|
125678
|
+
return new InferenceCredentialsError(detail || "The provider refused the key.");
|
|
125679
|
+
}
|
|
125680
|
+
if (status === 404) {
|
|
125681
|
+
return new InferenceCredentialsError("This Repoburg version cannot save keys here. Update Repoburg.");
|
|
125682
|
+
}
|
|
125683
|
+
return error51;
|
|
125684
|
+
}
|
|
125363
125685
|
async function getCommands3(cwd) {
|
|
125364
125686
|
try {
|
|
125365
125687
|
const resolved = await resolveBackendUrl(cwd ?? process.cwd(), { autoStart: false });
|
|
@@ -125384,6 +125706,9 @@ var repoburgProvider = {
|
|
|
125384
125706
|
clearThreadBranch: clearThreadBranch3,
|
|
125385
125707
|
clearAllThreads: clearAllThreads3,
|
|
125386
125708
|
getModels: getModels3,
|
|
125709
|
+
getInferenceProviders,
|
|
125710
|
+
setInferenceCredentials,
|
|
125711
|
+
removeInferenceCredentials,
|
|
125387
125712
|
getCommands: getCommands3,
|
|
125388
125713
|
rewindRuntime,
|
|
125389
125714
|
forkSession: forkSession2,
|