@adminforth/agent 2.7.0 → 2.7.2
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.
|
@@ -70,12 +70,13 @@ export declare class RunTurnUseCase {
|
|
|
70
70
|
* MemorySaver the in-process cache is authoritative (single process, cannot be stale).
|
|
71
71
|
*/
|
|
72
72
|
private resolvePendingInterrupts;
|
|
73
|
+
private requiresSessionOwnership;
|
|
73
74
|
/** Verify the session exists and belongs to the requesting admin user. */
|
|
74
75
|
private assertSessionOwnership;
|
|
75
76
|
/**
|
|
76
|
-
* Prepare an edit/branch turn:
|
|
77
|
-
*
|
|
78
|
-
*
|
|
77
|
+
* Prepare an edit/branch turn: resolve the fork checkpoint from the previous turn,
|
|
78
|
+
* truncate the conversation after the edited turn, and reuse the edited turn's id
|
|
79
|
+
* for the regenerated response. Ownership is already asserted by `prepareTurn`.
|
|
79
80
|
*/
|
|
80
81
|
private prepareEditTurn;
|
|
81
82
|
private prepareTurn;
|
|
@@ -121,6 +121,9 @@ export class RunTurnUseCase {
|
|
|
121
121
|
return (_a = this.pendingInterrupts.get(sessionId)) !== null && _a !== void 0 ? _a : [];
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
|
+
requiresSessionOwnership(input) {
|
|
125
|
+
return !input.chatSurface;
|
|
126
|
+
}
|
|
124
127
|
/** Verify the session exists and belongs to the requesting admin user. */
|
|
125
128
|
assertSessionOwnership(sessionId, adminUser) {
|
|
126
129
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -135,9 +138,9 @@ export class RunTurnUseCase {
|
|
|
135
138
|
});
|
|
136
139
|
}
|
|
137
140
|
/**
|
|
138
|
-
* Prepare an edit/branch turn:
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
+
* Prepare an edit/branch turn: resolve the fork checkpoint from the previous turn,
|
|
142
|
+
* truncate the conversation after the edited turn, and reuse the edited turn's id
|
|
143
|
+
* for the regenerated response. Ownership is already asserted by `prepareTurn`.
|
|
141
144
|
*/
|
|
142
145
|
prepareEditTurn(input) {
|
|
143
146
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -147,7 +150,6 @@ export class RunTurnUseCase {
|
|
|
147
150
|
if (!this.deps.turnCheckpointsEnabled) {
|
|
148
151
|
throw new Error("Edit/fork requires checkpointIdField to be configured on turnResource.");
|
|
149
152
|
}
|
|
150
|
-
yield this.assertSessionOwnership(input.sessionId, input.adminUser);
|
|
151
153
|
const agentTurns = yield this.deps.sessions.getAgentTurns(input.sessionId);
|
|
152
154
|
const targetIndex = agentTurns.findIndex((turn) => turn.id === editTurnId);
|
|
153
155
|
if (targetIndex === -1) {
|
|
@@ -201,6 +203,9 @@ export class RunTurnUseCase {
|
|
|
201
203
|
const mode = this.resolveMode(input.modeName);
|
|
202
204
|
const approvalDecision = getApprovalDecision(input);
|
|
203
205
|
const shouldResume = Boolean(approvalDecision);
|
|
206
|
+
if (this.requiresSessionOwnership(input)) {
|
|
207
|
+
yield this.assertSessionOwnership(input.sessionId, input.adminUser);
|
|
208
|
+
}
|
|
204
209
|
if (input.editTurnId && !shouldResume) {
|
|
205
210
|
return this.prepareEditTurn(input);
|
|
206
211
|
}
|