@absolutejs/voice 0.0.22-beta.190 → 0.0.22-beta.192

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.d.ts CHANGED
@@ -103,6 +103,7 @@ export type VoiceAgent<TContext = unknown, TSession extends VoiceSessionRecord =
103
103
  context: TContext;
104
104
  messages?: VoiceAgentMessage[];
105
105
  session: TSession;
106
+ system?: string;
106
107
  turn: VoiceTurnRecord;
107
108
  }) => Promise<VoiceAgentRunResult<TResult>>;
108
109
  };
@@ -6,6 +6,6 @@ export declare class VoiceLiveOpsService {
6
6
  isRunning: import("@angular/core").Signal<boolean>;
7
7
  lastResult: import("@angular/core").Signal<VoiceLiveOpsActionResult | undefined>;
8
8
  run: (input: import("..").VoiceLiveOpsActionInput) => Promise<VoiceLiveOpsActionResult | undefined>;
9
- runningAction: import("@angular/core").Signal<"escalate" | "assign" | "create-task" | "force-handoff" | "inject-instruction" | "operator-takeover" | "pause-assistant" | "resume-assistant" | "tag" | undefined>;
9
+ runningAction: import("@angular/core").Signal<"assign" | "create-task" | "escalate" | "force-handoff" | "inject-instruction" | "operator-takeover" | "pause-assistant" | "resume-assistant" | "tag" | undefined>;
10
10
  };
11
11
  }
@@ -37,7 +37,7 @@ export { createVoiceTraceTimelineViewModel, defineVoiceTraceTimelineElement, get
37
37
  export { createVoiceWorkflowStatusStore, fetchVoiceWorkflowStatus } from './workflowStatus';
38
38
  export type { VoiceOpsStatusClientOptions, VoiceOpsStatusSnapshot } from './opsStatus';
39
39
  export type { VoiceOpsActionCenterClientOptions, VoiceOpsActionCenterPresetOptions, VoiceOpsActionCenterSnapshot, VoiceOpsActionDescriptor, VoiceOpsActionMethod, VoiceOpsActionRunResult } from './opsActionCenter';
40
- export type { VoiceLiveOpsClientOptions, VoiceLiveOpsSnapshot } from './liveOps';
40
+ export type { VoiceLiveOpsClientOptions, VoiceLiveOpsAction, VoiceLiveOpsActionInput, VoiceLiveOpsActionResult, VoiceLiveOpsSnapshot } from './liveOps';
41
41
  export type { VoiceOpsActionHistoryClientOptions, VoiceOpsActionHistorySnapshot } from './opsActionHistory';
42
42
  export type { VoiceDeliveryRuntimeClientOptions, VoiceDeliveryRuntimeAction, VoiceDeliveryRuntimeActionResult, VoiceDeliveryRuntimeSnapshot } from './deliveryRuntime';
43
43
  export type { VoiceBargeInMonitorOptions } from './bargeInMonitor';
package/dist/index.js CHANGED
@@ -4649,9 +4649,32 @@ var createVoiceSession = (options) => {
4649
4649
  });
4650
4650
  };
4651
4651
  const completeTurn = async (session, turn) => {
4652
+ const liveOpsControl = await options.liveOps?.getControl(options.id);
4653
+ if (liveOpsControl?.assistantPaused || liveOpsControl?.operatorTakeover) {
4654
+ await appendTrace({
4655
+ metadata: {
4656
+ source: "voice-live-ops"
4657
+ },
4658
+ payload: {
4659
+ action: "turn.skipped",
4660
+ control: liveOpsControl,
4661
+ reason: liveOpsControl.operatorTakeover ? "operator-takeover" : "assistant-paused",
4662
+ status: "skipped"
4663
+ },
4664
+ session,
4665
+ turnId: turn.id,
4666
+ type: "operator.action"
4667
+ });
4668
+ return;
4669
+ }
4670
+ const injectedInstruction = liveOpsControl?.injectedInstruction?.trim();
4652
4671
  const committedOutput = await options.route.onTurn({
4653
4672
  api,
4654
4673
  context: options.context,
4674
+ liveOps: liveOpsControl ? {
4675
+ control: liveOpsControl,
4676
+ injectedInstruction
4677
+ } : undefined,
4655
4678
  session,
4656
4679
  turn
4657
4680
  });
@@ -5407,6 +5430,7 @@ var voice = (config) => {
5407
5430
  handoff: config.handoff,
5408
5431
  languageStrategy: config.languageStrategy,
5409
5432
  lexicon,
5433
+ liveOps: config.liveOps,
5410
5434
  logger: sessionOptions.logger,
5411
5435
  phraseHints,
5412
5436
  reconnect: sessionOptions.reconnect,
@@ -6936,11 +6960,14 @@ var createVoiceAgent = (options) => {
6936
6960
  const run = async (input) => {
6937
6961
  const messages = input.messages ?? createHistoryMessages(input.session, input.turn);
6938
6962
  const toolResults = [];
6939
- const system = typeof options.system === "function" ? await options.system({
6963
+ const baseSystem = typeof options.system === "function" ? await options.system({
6940
6964
  context: input.context,
6941
6965
  session: input.session,
6942
6966
  turn: input.turn
6943
6967
  }) : options.system;
6968
+ const system = [baseSystem, input.system].filter((value) => Boolean(value?.trim())).join(`
6969
+
6970
+ `) || undefined;
6944
6971
  let output = {};
6945
6972
  for (let round = 0;round <= maxToolRounds; round += 1) {
6946
6973
  const modelStartedAt = Date.now();
@@ -7994,7 +8021,25 @@ var createVoiceAssistant = (options) => {
7994
8021
  trace: options.trace,
7995
8022
  tools: variant.tools ?? baseModelOptions.tools
7996
8023
  }) : agent;
7997
- const runResult = await runner.run(input) ?? {};
8024
+ const liveOpsInstruction = input.liveOps?.injectedInstruction?.trim();
8025
+ if (liveOpsInstruction) {
8026
+ await appendAssistantTrace({
8027
+ assistantId: options.id,
8028
+ event: {
8029
+ action: "instruction-injected",
8030
+ artifactPlan: artifactPlanName,
8031
+ instruction: liveOpsInstruction
8032
+ },
8033
+ session: input.session,
8034
+ trace: options.trace,
8035
+ turnId: input.turn.id,
8036
+ type: "assistant.run"
8037
+ });
8038
+ }
8039
+ const runResult = await runner.run({
8040
+ ...input,
8041
+ system: liveOpsInstruction ? `Operator instruction for this turn: ${liveOpsInstruction}` : undefined
8042
+ }) ?? {};
7998
8043
  const result = runResult;
7999
8044
  const guarded = await options.guardrails?.afterTurn?.({
8000
8045
  ...guardrailInput,
@@ -6401,9 +6401,32 @@ var createVoiceSession = (options) => {
6401
6401
  });
6402
6402
  };
6403
6403
  const completeTurn = async (session, turn) => {
6404
+ const liveOpsControl = await options.liveOps?.getControl(options.id);
6405
+ if (liveOpsControl?.assistantPaused || liveOpsControl?.operatorTakeover) {
6406
+ await appendTrace({
6407
+ metadata: {
6408
+ source: "voice-live-ops"
6409
+ },
6410
+ payload: {
6411
+ action: "turn.skipped",
6412
+ control: liveOpsControl,
6413
+ reason: liveOpsControl.operatorTakeover ? "operator-takeover" : "assistant-paused",
6414
+ status: "skipped"
6415
+ },
6416
+ session,
6417
+ turnId: turn.id,
6418
+ type: "operator.action"
6419
+ });
6420
+ return;
6421
+ }
6422
+ const injectedInstruction = liveOpsControl?.injectedInstruction?.trim();
6404
6423
  const committedOutput = await options.route.onTurn({
6405
6424
  api,
6406
6425
  context: options.context,
6426
+ liveOps: liveOpsControl ? {
6427
+ control: liveOpsControl,
6428
+ injectedInstruction
6429
+ } : undefined,
6407
6430
  session,
6408
6431
  turn
6409
6432
  });
package/dist/types.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { VoiceOpsDispositionTaskPolicies, VoiceOpsTaskAssignmentRule, Voice
3
3
  import type { VoiceIntegrationSink } from './opsSinks';
4
4
  import type { StoredVoiceCallReviewArtifact, VoiceCallReviewArtifact, VoiceCallReviewStore } from './testing/review';
5
5
  import type { VoiceTraceEventStore } from './trace';
6
+ import type { VoiceLiveOpsControlState } from './liveOps';
6
7
  export type AudioFormat = {
7
8
  container: 'raw';
8
9
  encoding: 'alaw' | 'mulaw' | 'pcm_s16le';
@@ -484,6 +485,10 @@ export type VoiceLexiconResolver<TContext = unknown> = (input: {
484
485
  }) => Promise<VoiceLexiconEntry[] | void> | VoiceLexiconEntry[] | void;
485
486
  export type VoiceOnTurnObjectHandler<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = (input: {
486
487
  context: TContext;
488
+ liveOps?: {
489
+ control: VoiceLiveOpsControlState;
490
+ injectedInstruction?: string;
491
+ };
487
492
  session: TSession;
488
493
  turn: VoiceTurnRecord;
489
494
  api: VoiceSessionHandle<TContext, TSession, TResult>;
@@ -605,6 +610,9 @@ export type VoiceRuntimeOpsConfig<TContext = unknown, TSession extends VoiceSess
605
610
  tasks?: VoiceOpsTaskStore;
606
611
  webhook?: VoiceIntegrationWebhookConfig;
607
612
  };
613
+ export type VoiceLiveOpsRuntimeConfig = {
614
+ getControl: (sessionId: string) => Promise<VoiceLiveOpsControlState | null | undefined> | VoiceLiveOpsControlState | null | undefined;
615
+ };
608
616
  export type VoiceNormalizedRouteConfig<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = Omit<VoiceRouteConfig<TContext, TSession, TResult>, 'onTurn'> & {
609
617
  onTurn: VoiceOnTurnObjectHandler<TContext, TSession, TResult>;
610
618
  };
@@ -639,6 +647,7 @@ export type VoicePluginConfig<TContext = unknown, TSession extends VoiceSessionR
639
647
  htmx?: boolean | VoiceHTMXConfig<TSession, NoInfer<TResult>>;
640
648
  handoff?: VoiceHandoffConfig<TContext, TSession, TResult>;
641
649
  ops?: VoiceRuntimeOpsConfig<TContext, TSession, TResult>;
650
+ liveOps?: VoiceLiveOpsRuntimeConfig;
642
651
  trace?: VoiceTraceEventStore;
643
652
  } & VoiceRouteConfig<TContext, TSession, TResult>;
644
653
  export type CreateVoiceSessionOptions<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
@@ -662,6 +671,7 @@ export type CreateVoiceSessionOptions<TContext = unknown, TSession extends Voice
662
671
  turnDetection: VoiceResolvedTurnDetectionConfig;
663
672
  audioConditioning?: VoiceResolvedAudioConditioningConfig;
664
673
  handoff?: VoiceHandoffConfig<TContext, TSession, TResult>;
674
+ liveOps?: VoiceLiveOpsRuntimeConfig;
665
675
  route: VoiceNormalizedRouteConfig<TContext, TSession, TResult>;
666
676
  logger?: VoiceLogger;
667
677
  };
@@ -4,6 +4,6 @@ export declare function useVoiceLiveOps(options?: VoiceLiveOpsClientOptions): {
4
4
  isRunning: import("vue").Ref<boolean, boolean>;
5
5
  lastResult: import("vue").ShallowRef<VoiceLiveOpsActionResult | undefined, VoiceLiveOpsActionResult | undefined>;
6
6
  run: (input: import("..").VoiceLiveOpsActionInput) => Promise<VoiceLiveOpsActionResult | undefined>;
7
- runningAction: import("vue").Ref<"escalate" | "assign" | "create-task" | "force-handoff" | "inject-instruction" | "operator-takeover" | "pause-assistant" | "resume-assistant" | "tag" | undefined, "escalate" | "assign" | "create-task" | "force-handoff" | "inject-instruction" | "operator-takeover" | "pause-assistant" | "resume-assistant" | "tag" | undefined>;
7
+ runningAction: import("vue").Ref<"assign" | "create-task" | "escalate" | "force-handoff" | "inject-instruction" | "operator-takeover" | "pause-assistant" | "resume-assistant" | "tag" | undefined, "assign" | "create-task" | "escalate" | "force-handoff" | "inject-instruction" | "operator-takeover" | "pause-assistant" | "resume-assistant" | "tag" | undefined>;
8
8
  updatedAt: import("vue").Ref<number | undefined, number | undefined>;
9
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/voice",
3
- "version": "0.0.22-beta.190",
3
+ "version": "0.0.22-beta.192",
4
4
  "description": "Voice primitives and Elysia plugin for AbsoluteJS",
5
5
  "repository": {
6
6
  "type": "git",