@adminforth/agent 2.7.3 → 2.7.5

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.
@@ -3,7 +3,7 @@ import type { AgentSessionStore } from "../persistence/sessionStore.js";
3
3
  import type { SteerBuffer } from "../domain/steerBuffer.js";
4
4
  import type { PluginOptions } from "../types.js";
5
5
  import type { LlmPort } from "./ports.js";
6
- import type { DebugSink, HandleTurnInput, HandleEditTurnInput, PendingInterrupt, RunAndPersistAgentResponseInput, RunAndPersistAgentResponseResult } from "../domain/turnTypes.js";
6
+ import type { BaseAgentTurnInput, DebugSink, HandleTurnInput, HandleEditTurnInput, PendingInterrupt, RunAndPersistAgentResponseInput, RunAndPersistAgentResponseResult } from "../domain/turnTypes.js";
7
7
  /**
8
8
  * Build the provider-agnostic resume payload for a human-in-the-loop turn.
9
9
  * Exported for unit testing; the LLM port wraps it into a LangGraph Command.
@@ -72,7 +72,7 @@ export declare class RunTurnUseCase {
72
72
  private resolvePendingInterrupts;
73
73
  private requiresSessionOwnership;
74
74
  /** Verify the session exists and belongs to the requesting admin user. */
75
- private assertSessionOwnership;
75
+ assertSessionOwnership(sessionId: string, adminUser: BaseAgentTurnInput["adminUser"]): Promise<void>;
76
76
  /**
77
77
  * Prepare an edit/branch turn: resolve the fork checkpoint from the previous turn,
78
78
  * truncate the conversation after the edited turn, and reuse the edited turn's id
@@ -126,8 +126,10 @@ async function onStartRecording() {
126
126
  agentAudio.playBeep(1000);
127
127
  }
128
128
 
129
- function onStopRecording() {
130
- agentAudio.playBeep(600);
129
+ function onStopRecording(playBeep = true) {
130
+ if (playBeep) {
131
+ agentAudio.playBeep(600);
132
+ }
131
133
  stopUserMedia();
132
134
  audioAmplitude.value = 0;
133
135
  showAudioWavesAnimation.value = false;
@@ -180,7 +182,7 @@ async function sendRecordForTranscription() {
180
182
  onBeforeUnmount(() => {
181
183
  stopUserMedia();
182
184
  agentStore.setIsAudioChatMode(false);
183
- onStopRecording();
185
+ onStopRecording(false);
184
186
  hideAnimationDebounced.cancel();
185
187
  sendUserRecordDebounced.cancel();
186
188
  });
package/dist/index.js CHANGED
@@ -154,10 +154,11 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
154
154
  handleTurn: this.runTurnUseCase.handleTurn.bind(this.runTurnUseCase),
155
155
  handleEditTurn: this.runTurnUseCase.handleEditTurn.bind(this.runTurnUseCase),
156
156
  handleSpeechTurn: this.speechTurnService.handle.bind(this.speechTurnService),
157
- steer: ({ sessionId, message }) => {
157
+ steer: (_a) => __awaiter(this, [_a], void 0, function* ({ sessionId, message, adminUser }) {
158
+ yield this.runTurnUseCase.assertSessionOwnership(sessionId, adminUser);
158
159
  const { id } = this.steerBuffer.add(sessionId, message);
159
160
  return { id, queued: this.steerBuffer.size(sessionId) };
160
- },
161
+ }),
161
162
  runAndPersistAgentResponse: this.runTurnUseCase.runAndPersistAgentResponse.bind(this.runTurnUseCase),
162
163
  getSessionTurns: this.sessionStore.getSessionTurns.bind(this.sessionStore),
163
164
  createNewTurn: this.sessionStore.createNewTurn.bind(this.sessionStore),
@@ -15,10 +15,11 @@ export type AgentEndpointsContext = {
15
15
  steer(input: {
16
16
  sessionId: string;
17
17
  message: string;
18
- }): {
18
+ adminUser: any;
19
+ }): Promise<{
19
20
  id: string;
20
21
  queued: number;
21
- };
22
+ }>;
22
23
  runAndPersistAgentResponse(input: RunAndPersistAgentResponseInput): Promise<RunAndPersistAgentResponseResult>;
23
24
  getSessionTurns(sessionId: string): Promise<SessionTurn[]>;
24
25
  createNewTurn(sessionId: string, prompt: string, response?: string): Promise<string>;
@@ -167,14 +167,15 @@ export function setupCoreEndpoints(ctx, server) {
167
167
  method: 'POST',
168
168
  path: `/agent/steer`,
169
169
  request_schema: agentSteerBodySchema,
170
- handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body }) {
170
+ handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser }) {
171
171
  const data = body;
172
172
  // Fire-and-forget: the steer is buffered and folded into the running turn by the
173
173
  // beforeModel steer middleware, which signals `data-steer-applied` on that turn's
174
174
  // SSE stream once consumed. This endpoint only confirms it was received/queued.
175
- const { id, queued } = ctx.steer({
175
+ const { id, queued } = yield ctx.steer({
176
176
  sessionId: data.sessionId,
177
177
  message: data.message,
178
+ adminUser: adminUser
178
179
  });
179
180
  return { ok: true, id, queued };
180
181
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/agent",
3
- "version": "2.7.3",
3
+ "version": "2.7.5",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",