@absolutejs/voice 0.0.22-beta.152 → 0.0.22-beta.154

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.
@@ -0,0 +1,50 @@
1
+ export type VoiceOpsActionMethod = 'GET' | 'POST';
2
+ export type VoiceOpsActionDescriptor = {
3
+ description?: string;
4
+ disabled?: boolean;
5
+ id: string;
6
+ label: string;
7
+ method?: VoiceOpsActionMethod;
8
+ path: string;
9
+ };
10
+ export type VoiceOpsActionCenterClientOptions = {
11
+ actions?: VoiceOpsActionDescriptor[];
12
+ fetch?: typeof fetch;
13
+ intervalMs?: number;
14
+ };
15
+ export type VoiceOpsActionRunResult = {
16
+ actionId: string;
17
+ body: unknown;
18
+ ok: boolean;
19
+ ranAt: number;
20
+ status: number;
21
+ };
22
+ export type VoiceOpsActionCenterSnapshot = {
23
+ actions: VoiceOpsActionDescriptor[];
24
+ error: string | null;
25
+ isRunning: boolean;
26
+ lastResult?: VoiceOpsActionRunResult;
27
+ runningActionId?: string;
28
+ updatedAt?: number;
29
+ };
30
+ export type VoiceOpsActionCenterPresetOptions = {
31
+ deliveryRuntimePath?: string;
32
+ includeDeliveryRuntime?: boolean;
33
+ includeProductionReadiness?: boolean;
34
+ includeProviderSimulation?: boolean;
35
+ includeTurnLatencyProof?: boolean;
36
+ productionReadinessPath?: string;
37
+ providerSimulationPathPrefix?: string;
38
+ providers?: readonly string[];
39
+ turnLatencyProofPath?: string;
40
+ };
41
+ export declare const createVoiceOpsActionCenterActions: (options?: VoiceOpsActionCenterPresetOptions) => VoiceOpsActionDescriptor[];
42
+ export declare const runVoiceOpsAction: (action: VoiceOpsActionDescriptor, options?: Pick<VoiceOpsActionCenterClientOptions, "fetch">) => Promise<VoiceOpsActionRunResult>;
43
+ export declare const createVoiceOpsActionCenterStore: (options?: VoiceOpsActionCenterClientOptions) => {
44
+ close: () => void;
45
+ getServerSnapshot: () => VoiceOpsActionCenterSnapshot;
46
+ getSnapshot: () => VoiceOpsActionCenterSnapshot;
47
+ run: (actionId: string) => Promise<VoiceOpsActionRunResult | undefined>;
48
+ setActions: (actions: VoiceOpsActionDescriptor[]) => void;
49
+ subscribe: (listener: () => void) => () => void;
50
+ };
@@ -0,0 +1,29 @@
1
+ import { type VoiceOpsActionCenterClientOptions, type VoiceOpsActionCenterSnapshot } from './opsActionCenter';
2
+ export type VoiceOpsActionCenterViewModel = {
3
+ actions: Array<{
4
+ description: string;
5
+ disabled: boolean;
6
+ id: string;
7
+ isRunning: boolean;
8
+ label: string;
9
+ }>;
10
+ description: string;
11
+ error: string | null;
12
+ isRunning: boolean;
13
+ label: string;
14
+ lastResultLabel: string;
15
+ status: 'ready' | 'running' | 'error' | 'completed';
16
+ title: string;
17
+ };
18
+ export type VoiceOpsActionCenterWidgetOptions = VoiceOpsActionCenterClientOptions & {
19
+ description?: string;
20
+ title?: string;
21
+ };
22
+ export declare const createVoiceOpsActionCenterViewModel: (snapshot: VoiceOpsActionCenterSnapshot, options?: VoiceOpsActionCenterWidgetOptions) => VoiceOpsActionCenterViewModel;
23
+ export declare const renderVoiceOpsActionCenterHTML: (snapshot: VoiceOpsActionCenterSnapshot, options?: VoiceOpsActionCenterWidgetOptions) => string;
24
+ export declare const getVoiceOpsActionCenterCSS: () => string;
25
+ export declare const mountVoiceOpsActionCenter: (element: Element, options?: VoiceOpsActionCenterWidgetOptions) => {
26
+ close: () => void;
27
+ run: (actionId: string) => Promise<import("./opsActionCenter").VoiceOpsActionRunResult | undefined>;
28
+ };
29
+ export declare const defineVoiceOpsActionCenterElement: (tagName?: string, options?: VoiceOpsActionCenterWidgetOptions) => void;
@@ -21,6 +21,11 @@ export type VoiceDeliveryRuntimeTickResult = {
21
21
  audit?: VoiceAuditSinkDeliveryWorkerResult;
22
22
  trace?: VoiceTraceSinkDeliveryWorkerResult;
23
23
  };
24
+ export type VoiceDeliveryRuntimeRequeueDeadLettersResult = {
25
+ audit: number;
26
+ trace: number;
27
+ total: number;
28
+ };
24
29
  export type VoiceDeliveryRuntimeSummary = {
25
30
  audit?: VoiceAuditSinkDeliveryQueueSummary;
26
31
  trace?: VoiceTraceSinkDeliveryQueueSummary;
@@ -28,6 +33,7 @@ export type VoiceDeliveryRuntimeSummary = {
28
33
  export type VoiceDeliveryRuntime = {
29
34
  audit?: ReturnType<typeof createVoiceAuditSinkDeliveryWorker>;
30
35
  isRunning: () => boolean;
36
+ requeueDeadLetters: () => Promise<VoiceDeliveryRuntimeRequeueDeadLettersResult>;
31
37
  start: () => void;
32
38
  stop: () => void;
33
39
  summarize: () => Promise<VoiceDeliveryRuntimeSummary>;
@@ -44,8 +50,13 @@ export type VoiceDeliveryRuntimeRoutesOptions = {
44
50
  htmlPath?: false | string;
45
51
  name?: string;
46
52
  path?: string;
47
- render?: (report: VoiceDeliveryRuntimeReport) => string | Promise<string>;
53
+ render?: (report: VoiceDeliveryRuntimeReport, options: {
54
+ requeueDeadLettersPath?: false | string;
55
+ tickPath?: false | string;
56
+ title?: string;
57
+ }) => string | Promise<string>;
48
58
  runtime: VoiceDeliveryRuntime;
59
+ requeueDeadLettersPath?: false | string;
49
60
  tickPath?: false | string;
50
61
  title?: string;
51
62
  };
@@ -101,6 +112,7 @@ export declare const createVoiceDeliveryRuntimePresetConfig: (options: VoiceDeli
101
112
  export declare const createVoiceDeliveryRuntime: <TAuditDelivery extends VoiceAuditSinkDeliveryRecord = VoiceAuditSinkDeliveryRecord, TTraceDelivery extends VoiceTraceSinkDeliveryRecord = VoiceTraceSinkDeliveryRecord>(config: VoiceDeliveryRuntimeConfig<TAuditDelivery, TTraceDelivery>) => VoiceDeliveryRuntime;
102
113
  export declare const buildVoiceDeliveryRuntimeReport: (runtime: VoiceDeliveryRuntime) => Promise<VoiceDeliveryRuntimeReport>;
103
114
  export declare const renderVoiceDeliveryRuntimeHTML: (report: VoiceDeliveryRuntimeReport, options?: {
115
+ requeueDeadLettersPath?: false | string;
104
116
  tickPath?: false | string;
105
117
  title?: string;
106
118
  }) => string;
package/dist/index.js CHANGED
@@ -11579,6 +11579,15 @@ var resolvePresetLeases = (leases) => ("claim" in leases) ? {
11579
11579
  audit: leases,
11580
11580
  trace: leases
11581
11581
  } : leases;
11582
+ var requeueDelivery = (delivery) => ({
11583
+ ...delivery,
11584
+ deliveredAt: undefined,
11585
+ deliveryAttempts: 0,
11586
+ deliveryError: undefined,
11587
+ deliveryStatus: "pending",
11588
+ sinkDeliveries: undefined,
11589
+ updatedAt: Date.now()
11590
+ });
11582
11591
  var createDeliveryRuntimeFileSink = (input) => ({
11583
11592
  deliver: async ({ events }) => {
11584
11593
  const firstEvent = events[0];
@@ -11706,6 +11715,29 @@ var createVoiceDeliveryRuntime = (config) => {
11706
11715
  return {
11707
11716
  audit,
11708
11717
  isRunning: () => Boolean(auditLoop?.isRunning() || traceLoop?.isRunning()),
11718
+ requeueDeadLetters: async () => {
11719
+ let audit2 = 0;
11720
+ let trace2 = 0;
11721
+ if (config.audit?.deadLetters) {
11722
+ for (const delivery of await config.audit.deadLetters.list()) {
11723
+ await config.audit.deliveries.set(delivery.id, requeueDelivery(delivery));
11724
+ await config.audit.deadLetters.remove(delivery.id);
11725
+ audit2 += 1;
11726
+ }
11727
+ }
11728
+ if (config.trace?.deadLetters) {
11729
+ for (const delivery of await config.trace.deadLetters.list()) {
11730
+ await config.trace.deliveries.set(delivery.id, requeueDelivery(delivery));
11731
+ await config.trace.deadLetters.remove(delivery.id);
11732
+ trace2 += 1;
11733
+ }
11734
+ }
11735
+ return {
11736
+ audit: audit2,
11737
+ trace: trace2,
11738
+ total: audit2 + trace2
11739
+ };
11740
+ },
11709
11741
  start: () => {
11710
11742
  if (config.audit?.autoStart) {
11711
11743
  auditLoop?.start();
@@ -11753,15 +11785,18 @@ var buildVoiceDeliveryRuntimeReport = async (runtime) => ({
11753
11785
  var renderVoiceDeliveryRuntimeHTML = (report, options = {}) => {
11754
11786
  const title = options.title ?? "AbsoluteJS Voice Delivery Runtime";
11755
11787
  const tickForm = options.tickPath === false ? "" : `<form method="post" action="${escapeHtml15(options.tickPath ?? "/api/voice-delivery-runtime/tick")}"><button type="submit">Tick delivery workers</button></form>`;
11756
- return `<!doctype html><html lang="en"><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>${escapeHtml15(title)}</title><style>body{background:#0f1411;color:#f7f2df;font-family:ui-sans-serif,system-ui,sans-serif;margin:0}main{margin:auto;max-width:1080px;padding:32px}a{color:#86efac;text-decoration:none}.hero{background:linear-gradient(135deg,rgba(34,197,94,.18),rgba(14,165,233,.13));border:1px solid #263a30;border-radius:28px;margin-bottom:18px;padding:28px}.eyebrow{color:#86efac;font-weight:900;letter-spacing:.12em;text-transform:uppercase}h1{font-size:clamp(2.2rem,5vw,4.8rem);line-height:.92;margin:.2rem 0 1rem}.status{border:1px solid #64748b;border-radius:999px;display:inline-flex;font-weight:900;padding:8px 12px}.status.running{border-color:rgba(34,197,94,.7);color:#bbf7d0}.muted{color:#b9c3b4}.grid{display:grid;gap:14px;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));margin:18px 0}article,.card{background:#151d18;border:1px solid #263a30;border-radius:22px;padding:18px}article span{color:#b9c3b4;display:block;font-weight:800}article strong{display:block;font-size:2.3rem;margin-top:8px}button{background:#86efac;border:0;border-radius:999px;color:#07120b;cursor:pointer;font-weight:900;margin-top:12px;padding:10px 14px}pre{background:#09100c;border:1px solid #263a30;border-radius:18px;color:#dcfce7;overflow:auto;padding:16px}</style></head><body><main><p><a href="/delivery-sinks">Delivery sinks</a></p><section class="hero"><p class="eyebrow">Worker control plane</p><h1>${escapeHtml15(title)}</h1><p class="muted">Inspect queue summaries and manually tick audit and trace delivery workers from one runtime primitive.</p><p class="status ${report.isRunning ? "running" : ""}">${report.isRunning ? "Running" : "Stopped"}</p><p class="muted">Checked ${escapeHtml15(new Date(report.checkedAt).toLocaleString())}</p>${tickForm}</section><section class="grid">${renderSummaryCard("Audit", report.summary.audit)}${renderSummaryCard("Trace", report.summary.trace)}</section><section class="card"><h2>Runtime shape</h2><pre>const runtime = createVoiceDeliveryRuntime({ audit, trace })
11788
+ const requeueForm = options.requeueDeadLettersPath === false ? "" : `<form method="post" action="${escapeHtml15(options.requeueDeadLettersPath ?? "/api/voice-delivery-runtime/requeue-dead-letters")}"><button type="submit">Requeue dead letters</button></form>`;
11789
+ return `<!doctype html><html lang="en"><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>${escapeHtml15(title)}</title><style>body{background:#0f1411;color:#f7f2df;font-family:ui-sans-serif,system-ui,sans-serif;margin:0}main{margin:auto;max-width:1080px;padding:32px}a{color:#86efac;text-decoration:none}.hero{background:linear-gradient(135deg,rgba(34,197,94,.18),rgba(14,165,233,.13));border:1px solid #263a30;border-radius:28px;margin-bottom:18px;padding:28px}.eyebrow{color:#86efac;font-weight:900;letter-spacing:.12em;text-transform:uppercase}h1{font-size:clamp(2.2rem,5vw,4.8rem);line-height:.92;margin:.2rem 0 1rem}.status{border:1px solid #64748b;border-radius:999px;display:inline-flex;font-weight:900;padding:8px 12px}.status.running{border-color:rgba(34,197,94,.7);color:#bbf7d0}.muted{color:#b9c3b4}.grid{display:grid;gap:14px;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));margin:18px 0}article,.card{background:#151d18;border:1px solid #263a30;border-radius:22px;padding:18px}article span{color:#b9c3b4;display:block;font-weight:800}article strong{display:block;font-size:2.3rem;margin-top:8px}.actions{display:flex;flex-wrap:wrap;gap:10px}button{background:#86efac;border:0;border-radius:999px;color:#07120b;cursor:pointer;font-weight:900;margin-top:12px;padding:10px 14px}pre{background:#09100c;border:1px solid #263a30;border-radius:18px;color:#dcfce7;overflow:auto;padding:16px}</style></head><body><main><p><a href="/delivery-sinks">Delivery sinks</a></p><section class="hero"><p class="eyebrow">Worker control plane</p><h1>${escapeHtml15(title)}</h1><p class="muted">Inspect queue summaries, manually tick failed/pending audit and trace deliveries, and requeue dead letters after operator review.</p><p class="status ${report.isRunning ? "running" : ""}">${report.isRunning ? "Running" : "Stopped"}</p><p class="muted">Checked ${escapeHtml15(new Date(report.checkedAt).toLocaleString())}</p><div class="actions">${tickForm}${requeueForm}</div></section><section class="grid">${renderSummaryCard("Audit", report.summary.audit)}${renderSummaryCard("Trace", report.summary.trace)}</section><section class="card"><h2>Runtime shape</h2><pre>const runtime = createVoiceDeliveryRuntime({ audit, trace })
11757
11790
 
11758
11791
  await runtime.tick()
11792
+ await runtime.requeueDeadLetters()
11759
11793
  await runtime.summarize()</pre></section></main></body></html>`;
11760
11794
  };
11761
11795
  var createVoiceDeliveryRuntimeRoutes = (options) => {
11762
11796
  const path = options.path ?? "/api/voice-delivery-runtime";
11763
11797
  const htmlPath = options.htmlPath === undefined ? "/delivery-runtime" : options.htmlPath;
11764
11798
  const tickPath = options.tickPath === undefined ? "/api/voice-delivery-runtime/tick" : options.tickPath;
11799
+ const requeueDeadLettersPath = options.requeueDeadLettersPath === undefined ? "/api/voice-delivery-runtime/requeue-dead-letters" : options.requeueDeadLettersPath;
11765
11800
  const routes = new Elysia12({
11766
11801
  name: options.name ?? "absolutejs-voice-delivery-runtime"
11767
11802
  }).get(path, () => buildVoiceDeliveryRuntimeReport(options.runtime));
@@ -11772,11 +11807,19 @@ var createVoiceDeliveryRuntimeRoutes = (options) => {
11772
11807
  summary: await options.runtime.summarize()
11773
11808
  }));
11774
11809
  }
11810
+ if (requeueDeadLettersPath !== false) {
11811
+ routes.post(requeueDeadLettersPath, async () => ({
11812
+ requeuedAt: Date.now(),
11813
+ result: await options.runtime.requeueDeadLetters(),
11814
+ summary: await options.runtime.summarize()
11815
+ }));
11816
+ }
11775
11817
  if (htmlPath !== false) {
11776
11818
  routes.get(htmlPath, async () => {
11777
11819
  const report = await buildVoiceDeliveryRuntimeReport(options.runtime);
11778
11820
  const body = await (options.render ?? renderVoiceDeliveryRuntimeHTML)(report, {
11779
11821
  tickPath,
11822
+ requeueDeadLettersPath,
11780
11823
  title: options.title
11781
11824
  });
11782
11825
  return new Response(body, {
@@ -1,6 +1,7 @@
1
1
  import { type VoiceDeliveryRuntimeWidgetOptions } from '../client/deliveryRuntimeWidget';
2
2
  export type VoiceDeliveryRuntimeProps = VoiceDeliveryRuntimeWidgetOptions & {
3
3
  className?: string;
4
+ includeActions?: boolean;
4
5
  path?: string;
5
6
  };
6
- export declare const VoiceDeliveryRuntime: ({ className, path, ...options }: VoiceDeliveryRuntimeProps) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const VoiceDeliveryRuntime: ({ className, includeActions, path, ...options }: VoiceDeliveryRuntimeProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { type VoiceOpsActionCenterWidgetOptions } from '../client/opsActionCenterWidget';
2
+ export type VoiceOpsActionCenterProps = VoiceOpsActionCenterWidgetOptions & {
3
+ className?: string;
4
+ };
5
+ export declare const VoiceOpsActionCenter: ({ className, ...options }: VoiceOpsActionCenterProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,5 @@
1
1
  export { VoiceOpsStatus } from './VoiceOpsStatus';
2
+ export { VoiceOpsActionCenter } from './VoiceOpsActionCenter';
2
3
  export { VoiceDeliveryRuntime } from './VoiceDeliveryRuntime';
3
4
  export { VoiceProviderSimulationControls } from './VoiceProviderSimulationControls';
4
5
  export { VoiceProviderCapabilities } from './VoiceProviderCapabilities';
@@ -8,6 +9,7 @@ export { VoiceTraceTimeline } from './VoiceTraceTimeline';
8
9
  export { VoiceTurnLatency } from './VoiceTurnLatency';
9
10
  export { VoiceTurnQuality } from './VoiceTurnQuality';
10
11
  export { useVoiceOpsStatus } from './useVoiceOpsStatus';
12
+ export { useVoiceOpsActionCenter } from './useVoiceOpsActionCenter';
11
13
  export { useVoiceDeliveryRuntime } from './useVoiceDeliveryRuntime';
12
14
  export { useVoiceCampaignDialerProof } from './useVoiceCampaignDialerProof';
13
15
  export { useVoiceStream } from './useVoiceStream';