@absolutejs/voice 0.0.22-beta.409 → 0.0.22-beta.410
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/README.md +28 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +207 -0
- package/dist/proofPack.d.ts +92 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1456,6 +1456,34 @@ app.use(
|
|
|
1456
1456
|
);
|
|
1457
1457
|
```
|
|
1458
1458
|
|
|
1459
|
+
Use `buildVoiceProofPack(...)` and `writeVoiceProofPack(...)` when the app needs a customer-owned proof artifact instead of demo-only file glue. Proof packs render JSON and Markdown, expose route helpers, and can be converted into observability export artifacts:
|
|
1460
|
+
|
|
1461
|
+
```ts
|
|
1462
|
+
import {
|
|
1463
|
+
buildVoiceProofPackFromObservabilityExport,
|
|
1464
|
+
createVoiceProofPackRoutes,
|
|
1465
|
+
writeVoiceProofPack
|
|
1466
|
+
} from '@absolutejs/voice';
|
|
1467
|
+
|
|
1468
|
+
const exportReport = await buildVoiceObservabilityExport({
|
|
1469
|
+
store: runtime.traces,
|
|
1470
|
+
audit: runtime.audit
|
|
1471
|
+
});
|
|
1472
|
+
const proofPack = buildVoiceProofPackFromObservabilityExport(exportReport, {
|
|
1473
|
+
runId: 'release-proof'
|
|
1474
|
+
});
|
|
1475
|
+
const written = await writeVoiceProofPack(proofPack, {
|
|
1476
|
+
outputDir: '.voice-runtime/proof-pack'
|
|
1477
|
+
});
|
|
1478
|
+
|
|
1479
|
+
app.use(createVoiceProofPackRoutes({ source: proofPack }));
|
|
1480
|
+
|
|
1481
|
+
const exportWithProofPack = await buildVoiceObservabilityExport({
|
|
1482
|
+
artifacts: written.artifacts,
|
|
1483
|
+
store: runtime.traces
|
|
1484
|
+
});
|
|
1485
|
+
```
|
|
1486
|
+
|
|
1459
1487
|
This primitive does not start workers, create persistent storage, mount a dashboard, or prescribe a deploy workflow. It only gives self-hosted apps one clean readiness-proof runtime so JSON, HTML, gate checks, proof packs, and trend artifacts agree on the same fresh evidence window.
|
|
1460
1488
|
|
|
1461
1489
|
Use `buildVoiceRealCallProfileEvidenceFromTraceEvents(...)` or `loadVoiceRealCallProfileEvidenceFromTraceStore(...)` when repeated real browser/phone sessions should drive profile defaults and provider/runtime recommendations. These helpers read ordinary trace events such as `session.error`, `provider.decision`, `client.live_latency`, `client.browser_media`, `client.telephony_media`, `client.barge_in`, and `turn_latency.stage`, then emit `VoiceProofTrendRealCallProfileEvidence[]` for `buildVoiceRealCallProfileHistoryReport(...)`.
|
package/dist/index.d.ts
CHANGED
|
@@ -206,4 +206,6 @@ export type { PlivoInboundMessage, PlivoMediaStreamBridge, PlivoMediaStreamBridg
|
|
|
206
206
|
export type { VoiceTelephonyCarrierMatrix, VoiceTelephonyCarrierMatrixEntry, VoiceTelephonyCarrierMatrixInput, VoiceTelephonyCarrierMatrixOptions, VoiceTelephonyCarrierMatrixRoutesOptions, VoiceTelephonyCarrierMatrixStatus } from './telephony/matrix';
|
|
207
207
|
export { shapeTelephonyAssistantText } from './telephony/response';
|
|
208
208
|
export type { TelephonyResponseShapeMode, TelephonyResponseShapeOptions } from './telephony/response';
|
|
209
|
+
export { buildVoiceProofPack, buildVoiceProofPackFromObservabilityExport, createVoiceProofPackArtifacts, createVoiceProofPackRoutes, renderVoiceProofPackMarkdown, writeVoiceProofPack } from './proofPack';
|
|
210
|
+
export type { VoiceProofPack, VoiceProofPackEvidence, VoiceProofPackInput, VoiceProofPackRoutesOptions, VoiceProofPackSection, VoiceProofPackStatus, VoiceProofPackWriteResult } from './proofPack';
|
|
209
211
|
export * from './types';
|
package/dist/index.js
CHANGED
|
@@ -39858,7 +39858,209 @@ var shapeTelephonyAssistantText = (text, options = {}) => {
|
|
|
39858
39858
|
const limitedChars = clampChars(limitedWords, options.maxChars);
|
|
39859
39859
|
return ensureTerminalPunctuation(normalizeWhitespace(limitedChars));
|
|
39860
39860
|
};
|
|
39861
|
+
// src/proofPack.ts
|
|
39862
|
+
import { Elysia as Elysia66 } from "elysia";
|
|
39863
|
+
import { mkdir as mkdir5 } from "fs/promises";
|
|
39864
|
+
import { dirname as dirname3, join as join4 } from "path";
|
|
39865
|
+
var toGeneratedAt = (value) => value === undefined ? new Date().toISOString() : typeof value === "number" ? new Date(value).toISOString() : value;
|
|
39866
|
+
var summarizeProofPackSections = (sections) => {
|
|
39867
|
+
let pass = 0;
|
|
39868
|
+
let warn = 0;
|
|
39869
|
+
let fail = 0;
|
|
39870
|
+
for (const section of sections) {
|
|
39871
|
+
const statuses = [
|
|
39872
|
+
section.status,
|
|
39873
|
+
...(section.evidence ?? []).map((evidence) => evidence.status)
|
|
39874
|
+
].filter((status) => Boolean(status));
|
|
39875
|
+
if (statuses.some((status) => status === "fail")) {
|
|
39876
|
+
fail += 1;
|
|
39877
|
+
} else if (statuses.some((status) => status === "warn")) {
|
|
39878
|
+
warn += 1;
|
|
39879
|
+
} else {
|
|
39880
|
+
pass += 1;
|
|
39881
|
+
}
|
|
39882
|
+
}
|
|
39883
|
+
return { fail, pass, sections: sections.length, warn };
|
|
39884
|
+
};
|
|
39885
|
+
var resolveProofPack = async (source) => {
|
|
39886
|
+
const input = typeof source === "function" ? await source() : source;
|
|
39887
|
+
return buildVoiceProofPack(input);
|
|
39888
|
+
};
|
|
39889
|
+
var buildVoiceProofPack = (input) => {
|
|
39890
|
+
if ("status" in input && "ok" in input && "summary" in input && Array.isArray(input.sections)) {
|
|
39891
|
+
return input;
|
|
39892
|
+
}
|
|
39893
|
+
const sections = input.sections ?? [];
|
|
39894
|
+
const summary = summarizeProofPackSections(sections);
|
|
39895
|
+
const status = summary.fail > 0 ? "fail" : summary.warn > 0 ? "warn" : "pass";
|
|
39896
|
+
return {
|
|
39897
|
+
artifacts: input.artifacts ?? [],
|
|
39898
|
+
generatedAt: toGeneratedAt(input.generatedAt),
|
|
39899
|
+
ok: status === "pass",
|
|
39900
|
+
outputDir: input.outputDir,
|
|
39901
|
+
runId: input.runId ?? `voice-proof-pack-${crypto.randomUUID()}`,
|
|
39902
|
+
sections,
|
|
39903
|
+
status,
|
|
39904
|
+
summary
|
|
39905
|
+
};
|
|
39906
|
+
};
|
|
39907
|
+
var buildVoiceProofPackFromObservabilityExport = (report, input = {}) => buildVoiceProofPack({
|
|
39908
|
+
...input,
|
|
39909
|
+
artifacts: report.artifacts,
|
|
39910
|
+
generatedAt: input.generatedAt ?? report.checkedAt,
|
|
39911
|
+
sections: [
|
|
39912
|
+
{
|
|
39913
|
+
evidence: [
|
|
39914
|
+
{
|
|
39915
|
+
label: "Trace events",
|
|
39916
|
+
status: report.summary.traceEvents > 0 ? "pass" : "warn",
|
|
39917
|
+
value: report.summary.traceEvents
|
|
39918
|
+
},
|
|
39919
|
+
{
|
|
39920
|
+
label: "Audit events",
|
|
39921
|
+
status: report.summary.auditEvents > 0 ? "pass" : "warn",
|
|
39922
|
+
value: report.summary.auditEvents
|
|
39923
|
+
},
|
|
39924
|
+
{
|
|
39925
|
+
label: "Artifacts",
|
|
39926
|
+
status: report.artifacts.some((artifact) => artifact.status === "fail") ? "fail" : report.artifacts.some((artifact) => artifact.status === "warn") ? "warn" : "pass",
|
|
39927
|
+
value: report.artifacts.length
|
|
39928
|
+
}
|
|
39929
|
+
],
|
|
39930
|
+
status: report.status,
|
|
39931
|
+
summary: "Customer-owned observability export evidence.",
|
|
39932
|
+
title: "Observability export"
|
|
39933
|
+
},
|
|
39934
|
+
{
|
|
39935
|
+
evidence: report.issues.map((issue) => ({
|
|
39936
|
+
detail: issue.detail,
|
|
39937
|
+
label: issue.label,
|
|
39938
|
+
status: issue.severity,
|
|
39939
|
+
value: issue.value
|
|
39940
|
+
})),
|
|
39941
|
+
status: report.status,
|
|
39942
|
+
summary: report.issues.length === 0 ? "No export issues were reported." : `${report.issues.length} export issue(s) were reported.`,
|
|
39943
|
+
title: "Export issues"
|
|
39944
|
+
}
|
|
39945
|
+
]
|
|
39946
|
+
});
|
|
39947
|
+
var renderVoiceProofPackMarkdown = (proofPack) => {
|
|
39948
|
+
const sections = proofPack.sections.map((section) => {
|
|
39949
|
+
const evidence = (section.evidence ?? []).map((item) => {
|
|
39950
|
+
const value = item.value === undefined ? "" : `: ${String(item.value)}`;
|
|
39951
|
+
const href = item.href ? ` (${item.href})` : "";
|
|
39952
|
+
const detail = item.detail ? ` - ${item.detail}` : "";
|
|
39953
|
+
return `- ${item.label}${value}${href} - ${item.status ?? "pass"}${detail}`;
|
|
39954
|
+
}).join(`
|
|
39955
|
+
`);
|
|
39956
|
+
return [
|
|
39957
|
+
`## ${section.title}`,
|
|
39958
|
+
"",
|
|
39959
|
+
section.summary ?? "",
|
|
39960
|
+
"",
|
|
39961
|
+
evidence
|
|
39962
|
+
].filter(Boolean).join(`
|
|
39963
|
+
`);
|
|
39964
|
+
}).join(`
|
|
39965
|
+
|
|
39966
|
+
`);
|
|
39967
|
+
return [
|
|
39968
|
+
"# AbsoluteJS Voice Proof Pack",
|
|
39969
|
+
"",
|
|
39970
|
+
`Run: ${proofPack.runId}`,
|
|
39971
|
+
`Generated: ${proofPack.generatedAt}`,
|
|
39972
|
+
`Status: ${proofPack.status}`,
|
|
39973
|
+
"",
|
|
39974
|
+
`Sections: ${proofPack.summary.sections}`,
|
|
39975
|
+
`Passing sections: ${proofPack.summary.pass}`,
|
|
39976
|
+
`Warning sections: ${proofPack.summary.warn}`,
|
|
39977
|
+
`Failing sections: ${proofPack.summary.fail}`,
|
|
39978
|
+
"",
|
|
39979
|
+
sections
|
|
39980
|
+
].filter(Boolean).join(`
|
|
39981
|
+
`);
|
|
39982
|
+
};
|
|
39983
|
+
var writeVoiceProofPack = async (input, options = { outputDir: ".voice-runtime/proof-pack" }) => {
|
|
39984
|
+
const proofPack = buildVoiceProofPack({
|
|
39985
|
+
...input,
|
|
39986
|
+
outputDir: options.outputDir
|
|
39987
|
+
});
|
|
39988
|
+
const jsonPath = join4(options.outputDir, options.jsonFileName ?? "latest.json");
|
|
39989
|
+
const markdownPath = join4(options.outputDir, options.markdownFileName ?? "latest.md");
|
|
39990
|
+
await mkdir5(dirname3(jsonPath), { recursive: true });
|
|
39991
|
+
await mkdir5(dirname3(markdownPath), { recursive: true });
|
|
39992
|
+
await Promise.all([
|
|
39993
|
+
Bun.write(jsonPath, JSON.stringify(proofPack, null, 2)),
|
|
39994
|
+
Bun.write(markdownPath, renderVoiceProofPackMarkdown(proofPack))
|
|
39995
|
+
]);
|
|
39996
|
+
return {
|
|
39997
|
+
artifacts: createVoiceProofPackArtifacts({
|
|
39998
|
+
jsonPath,
|
|
39999
|
+
markdownPath,
|
|
40000
|
+
proofPack
|
|
40001
|
+
}),
|
|
40002
|
+
jsonPath,
|
|
40003
|
+
markdownPath,
|
|
40004
|
+
proofPack
|
|
40005
|
+
};
|
|
40006
|
+
};
|
|
40007
|
+
var createVoiceProofPackArtifacts = (input) => [
|
|
40008
|
+
...input.markdownPath ? [
|
|
40009
|
+
{
|
|
40010
|
+
generatedAt: input.proofPack.generatedAt,
|
|
40011
|
+
id: "latest-proof-pack",
|
|
40012
|
+
kind: "proof-pack",
|
|
40013
|
+
label: "Latest proof pack",
|
|
40014
|
+
metadata: {
|
|
40015
|
+
proofPackStatus: input.proofPack.status,
|
|
40016
|
+
runId: input.proofPack.runId
|
|
40017
|
+
},
|
|
40018
|
+
path: input.markdownPath,
|
|
40019
|
+
required: false,
|
|
40020
|
+
status: "pass"
|
|
40021
|
+
}
|
|
40022
|
+
] : [],
|
|
40023
|
+
...input.jsonPath ? [
|
|
40024
|
+
{
|
|
40025
|
+
contentType: "application/json",
|
|
40026
|
+
generatedAt: input.proofPack.generatedAt,
|
|
40027
|
+
id: "latest-proof-pack-json",
|
|
40028
|
+
kind: "proof-pack",
|
|
40029
|
+
label: "Latest proof pack JSON",
|
|
40030
|
+
metadata: {
|
|
40031
|
+
proofPackStatus: input.proofPack.status,
|
|
40032
|
+
runId: input.proofPack.runId
|
|
40033
|
+
},
|
|
40034
|
+
path: input.jsonPath,
|
|
40035
|
+
required: false,
|
|
40036
|
+
status: "pass"
|
|
40037
|
+
}
|
|
40038
|
+
] : []
|
|
40039
|
+
];
|
|
40040
|
+
var createVoiceProofPackRoutes = (options) => {
|
|
40041
|
+
const jsonPath = options.jsonPath ?? "/api/voice/proof-pack";
|
|
40042
|
+
const markdownPath = options.markdownPath ?? "/voice/proof-pack.md";
|
|
40043
|
+
const app = new Elysia66({ name: options.name ?? "voice-proof-pack" });
|
|
40044
|
+
if (jsonPath !== false) {
|
|
40045
|
+
app.get(jsonPath, async () => new Response(JSON.stringify(await resolveProofPack(options.source), null, 2), {
|
|
40046
|
+
headers: {
|
|
40047
|
+
"content-type": "application/json; charset=utf-8",
|
|
40048
|
+
...options.headers
|
|
40049
|
+
}
|
|
40050
|
+
}));
|
|
40051
|
+
}
|
|
40052
|
+
if (markdownPath !== false) {
|
|
40053
|
+
app.get(markdownPath, async () => new Response(renderVoiceProofPackMarkdown(await resolveProofPack(options.source)), {
|
|
40054
|
+
headers: {
|
|
40055
|
+
"content-type": "text/markdown; charset=utf-8",
|
|
40056
|
+
...options.headers
|
|
40057
|
+
}
|
|
40058
|
+
}));
|
|
40059
|
+
}
|
|
40060
|
+
return app;
|
|
40061
|
+
};
|
|
39861
40062
|
export {
|
|
40063
|
+
writeVoiceProofPack,
|
|
39862
40064
|
withVoiceOpsTaskId,
|
|
39863
40065
|
withVoiceIntegrationEventId,
|
|
39864
40066
|
voiceTelephonyOutcomeToRouteResult,
|
|
@@ -39993,6 +40195,7 @@ export {
|
|
|
39993
40195
|
renderVoiceProviderCapabilityHTML,
|
|
39994
40196
|
renderVoiceProofTrendRecommendationMarkdown,
|
|
39995
40197
|
renderVoiceProofTrendRecommendationHTML,
|
|
40198
|
+
renderVoiceProofPackMarkdown,
|
|
39996
40199
|
renderVoiceProfileSwitchReadinessHTML,
|
|
39997
40200
|
renderVoiceProfileSwitchPolicyProofHTML,
|
|
39998
40201
|
renderVoiceProfileSwitchLiveDecisionHTML,
|
|
@@ -40259,6 +40462,8 @@ export {
|
|
|
40259
40462
|
createVoiceProviderCapabilityHTMLHandler,
|
|
40260
40463
|
createVoiceProofTrendRoutes,
|
|
40261
40464
|
createVoiceProofTrendRecommendationRoutes,
|
|
40465
|
+
createVoiceProofPackRoutes,
|
|
40466
|
+
createVoiceProofPackArtifacts,
|
|
40262
40467
|
createVoiceProofAssertion,
|
|
40263
40468
|
createVoiceProfileTraceTagger,
|
|
40264
40469
|
createVoiceProfileSwitchReadinessRoutes,
|
|
@@ -40477,6 +40682,8 @@ export {
|
|
|
40477
40682
|
buildVoiceProofTrendReport,
|
|
40478
40683
|
buildVoiceProofTrendRecommendationReport,
|
|
40479
40684
|
buildVoiceProofTrendProfileSummaries,
|
|
40685
|
+
buildVoiceProofPackFromObservabilityExport,
|
|
40686
|
+
buildVoiceProofPack,
|
|
40480
40687
|
buildVoiceProfileSwitchReadinessReport,
|
|
40481
40688
|
buildVoiceProfileSwitchLiveDecisionReport,
|
|
40482
40689
|
buildVoiceProductionReadinessReport,
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Elysia } from 'elysia';
|
|
2
|
+
import type { VoiceObservabilityExportArtifact, VoiceObservabilityExportReport } from './observabilityExport';
|
|
3
|
+
export type VoiceProofPackStatus = 'fail' | 'pass' | 'warn';
|
|
4
|
+
export type VoiceProofPackEvidence = {
|
|
5
|
+
detail?: string;
|
|
6
|
+
href?: string;
|
|
7
|
+
label: string;
|
|
8
|
+
status?: VoiceProofPackStatus;
|
|
9
|
+
value?: number | string;
|
|
10
|
+
};
|
|
11
|
+
export type VoiceProofPackSection = {
|
|
12
|
+
evidence?: VoiceProofPackEvidence[];
|
|
13
|
+
status?: VoiceProofPackStatus;
|
|
14
|
+
summary?: string;
|
|
15
|
+
title: string;
|
|
16
|
+
};
|
|
17
|
+
export type VoiceProofPack = {
|
|
18
|
+
artifacts: VoiceObservabilityExportArtifact[];
|
|
19
|
+
generatedAt: string;
|
|
20
|
+
ok: boolean;
|
|
21
|
+
outputDir?: string;
|
|
22
|
+
runId: string;
|
|
23
|
+
sections: VoiceProofPackSection[];
|
|
24
|
+
status: VoiceProofPackStatus;
|
|
25
|
+
summary: {
|
|
26
|
+
fail: number;
|
|
27
|
+
pass: number;
|
|
28
|
+
sections: number;
|
|
29
|
+
warn: number;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export type VoiceProofPackInput = {
|
|
33
|
+
artifacts?: VoiceObservabilityExportArtifact[];
|
|
34
|
+
generatedAt?: number | string;
|
|
35
|
+
outputDir?: string;
|
|
36
|
+
runId?: string;
|
|
37
|
+
sections?: VoiceProofPackSection[];
|
|
38
|
+
};
|
|
39
|
+
export type VoiceProofPackWriteResult = {
|
|
40
|
+
artifacts: VoiceObservabilityExportArtifact[];
|
|
41
|
+
jsonPath: string;
|
|
42
|
+
markdownPath: string;
|
|
43
|
+
proofPack: VoiceProofPack;
|
|
44
|
+
};
|
|
45
|
+
export type VoiceProofPackRoutesOptions = {
|
|
46
|
+
headers?: HeadersInit;
|
|
47
|
+
jsonPath?: false | string;
|
|
48
|
+
markdownPath?: false | string;
|
|
49
|
+
name?: string;
|
|
50
|
+
source: VoiceProofPack | VoiceProofPackInput | (() => VoiceProofPack | VoiceProofPackInput | Promise<VoiceProofPack | VoiceProofPackInput>);
|
|
51
|
+
};
|
|
52
|
+
export declare const buildVoiceProofPack: (input: VoiceProofPackInput | VoiceProofPack) => VoiceProofPack;
|
|
53
|
+
export declare const buildVoiceProofPackFromObservabilityExport: (report: VoiceObservabilityExportReport, input?: Omit<VoiceProofPackInput, "artifacts" | "sections">) => VoiceProofPack;
|
|
54
|
+
export declare const renderVoiceProofPackMarkdown: (proofPack: VoiceProofPack) => string;
|
|
55
|
+
export declare const writeVoiceProofPack: (input: VoiceProofPackInput | VoiceProofPack, options?: {
|
|
56
|
+
jsonFileName?: string;
|
|
57
|
+
markdownFileName?: string;
|
|
58
|
+
outputDir: string;
|
|
59
|
+
}) => Promise<VoiceProofPackWriteResult>;
|
|
60
|
+
export declare const createVoiceProofPackArtifacts: (input: {
|
|
61
|
+
jsonPath?: string;
|
|
62
|
+
markdownPath?: string;
|
|
63
|
+
proofPack: VoiceProofPack;
|
|
64
|
+
}) => VoiceObservabilityExportArtifact[];
|
|
65
|
+
export declare const createVoiceProofPackRoutes: (options: VoiceProofPackRoutesOptions) => Elysia<"", {
|
|
66
|
+
decorator: {};
|
|
67
|
+
store: {};
|
|
68
|
+
derive: {};
|
|
69
|
+
resolve: {};
|
|
70
|
+
}, {
|
|
71
|
+
typebox: {};
|
|
72
|
+
error: {};
|
|
73
|
+
}, {
|
|
74
|
+
schema: {};
|
|
75
|
+
standaloneSchema: {};
|
|
76
|
+
macro: {};
|
|
77
|
+
macroFn: {};
|
|
78
|
+
parser: {};
|
|
79
|
+
response: {};
|
|
80
|
+
}, {}, {
|
|
81
|
+
derive: {};
|
|
82
|
+
resolve: {};
|
|
83
|
+
schema: {};
|
|
84
|
+
standaloneSchema: {};
|
|
85
|
+
response: {};
|
|
86
|
+
}, {
|
|
87
|
+
derive: {};
|
|
88
|
+
resolve: {};
|
|
89
|
+
schema: {};
|
|
90
|
+
standaloneSchema: {};
|
|
91
|
+
response: {};
|
|
92
|
+
}>;
|